Dubya....are you doing this project for something at work? (I thought it was for school)
Printable View
Dubya....are you doing this project for something at work? (I thought it was for school)
it's both actaully, i am in an internship but, i don't get paid a dime for it and i am getting graded on it. so it is required for my intership. is that still ok?
Oh yeah...no problem man...its just that if this was completely work related - I would provide more code. But we all feel that this type of help is detrimental to students, which is why I am trying to provide helpful hints and clues. (ps - guess I was lucky - I did 3 terms of internship or co-op as we call it and I got paid for it. I admire your tenacity - keep it up!!)
i think that my tenecity paid off, because i think that i finally got it to work. here is the code. let me know if you think there are bugs or an easier way to do it.
VB Code:
Private Sub Display() Dim found As Boolean If MachID <= 0 Then txtID.Text = rs(0) txtName.Text = rs(1) txtDesc.Text = rs(2) txtDepart.Text = rs(3) Else Do While (Not rs.EOF) And (Not found) If Val(rs(0)) <> MachID Then rs.MoveNext found = False Else found = True txtID.Text = rs(0) txtName.Text = rs(1) txtDesc.Text = rs(2) txtDepart.Text = rs(3) End If Loop If Not found Then txtID.Text = rs(0) txtName.Text = rs(1) txtDesc.Text = rs(2) txtDepart.Text = rs(3) End If End If End Sub
thanx for all your help man it has really helped me out alot dude, i just have to add more logic so i can do it more than once you know. i can go through it once, but when i try to do it again i get an error. i donno any thing about this though.
It is perfectly normal to encounter errors when trying to repeat something you just learned - we have all been there. I think the best way to counter act this is to really get to know the error messages and what they mean. Microsoft is notorious for raising ambiguous error descriptions (in my opinion), and it is all new to you, and that makes it even harder. But for the most part, if an error message says there is a type mismatch - there's a type mismatch somewhere - but if you the developer knows exactly what "type mismatch" means, finding the errors get easier and easier. Tell me something, do you step through code using F8? If not, let me know....this is an invaluable way to debug (it's really what ya pay the big bucks for when purchasing VB!)....plus you have the immediate window where you can type commands, execute them, and see the results (while your program is running). When I looked at your project and was checking out the variable machID, the first thing I did was a Debug.Print machID in the immediate window when that form was running to check its value - it had one so I knew right away that there was no problem with the variable. Let me know if you need more help in these areas. Cheers.
i donno any thing about F8 or the debug print. i got put into this internship after only 1 semester of VB6. i'm not even really supposed to be here but i am so i have to do this. so how do you step through the program with F8?
1. Toggling code:
In the code windows, you can click in the far left column (which is invisible) and toggle that line of code. A brown dot appears, and the line is highlited, and when you run that block of code, it will stop running at that line and the code window will open.
2. Stepping through:
Once you have toggled some code (another term is "create a break point"), and you run that block of code, the code window opens, highlights the line where you have toggled, and awaits your input. Pressing F8 advances the line of execution by one line. So you can literally execute your code line by line
3. Check values with mouse
As you step through line by line, position the cursor of your mouse of the variables - you will see their respective values appear, and sometimes you can quickly see what is wrong by doing this.
4. Use the immediate window
When you are stepping through, if the immediate window is not showing, go to menu 'View', then 'Immediate Window'. The immediate window is an editor that allows you to type things in it when your code breaks (as the result of a toggle you put in). The most common command issued here is 'Debug.Print' followed by what you want to print. You can print the value of a variable, or you can copy and paste code in here - for example - maybe you have a sql string that has variables embedded in it. You can copy this line of code into the immediate window and print it. And when you print it, it will give you the actual string you are passing with the actual values of the variables instead of the variable names. You can then copy and paste this string into a query in Access for example and run the query to see what errors you get.
5. Multiple break points
You can put as many break points (toggles) as you need. In some cases for example, you may be stepping through a block that has a loop in it. If you did not want to step through each iteration of the loop, you could put another break point on the line right after the loop. So when the first break point stops the code, once you have stepped into the loop, if you do not want to step through each iteration, you can click the run button which will advance to the next break point.
I really recommend that you spend atleast a day practicing these debugging techniques. The is one of the really great things that the VB IDE offers. By the way, on my first 'intern', I worked for TD Waterhouse - I had to design an inventory system for about 1,000 servers using ASP and SQL Server. I did not have any course from school (we learned VB and Access), so I had to fly by the seat of my pants as they say....but what an outstanding learning experience - truly invaluable. ;)
thanx a lot for all the help, i am going to try this stuf @ home on my own comp. i've included my projest this time so i can get it @ home. if u get a chance look @ it and see if you can find some of the errors.
hello;
I made a few minor changes to your code....see if you can spot them and why I did them. Cheers.
i looked and i see that you made some changes and that is cool, i was trying to do all of those things. i has thought about doing some thing with that mode thing but i didn't know how to go about it. thanx a lot man. i just have one more problem with that and i should be able to say that it is finished. one of the id numbers has both letters and numbers(i did this on purpose). i need to know how to get the app so it will load the one with numbers and letters as well. it will load all of the other ones but i need to load this one too. so i think that i need to change the data type. am i correct?
I cannot remember what data type you used (machID?? - Integer??) It should be a String if the values are alphanumeric, and you would use the ItemData collection to store this value as it stores Strings. Also, do not forget that in sql, strings must be delimited with a single quote:
Plus, you would have to redifine your showList sub to accept a String as an argument instead of Integer.Code:sql = "select * from tblMachines where machID='" & machID & "'"
ok thanx alot man. i'll give it a shot, this project has turned out to be........bigger and harder than i thought but thanx to u i can do it. i have another question for u tho, is it possible to read values in from a query in access? i have to be able to do that as well.
You already do that when you populate your combo box - please be more specific with your question - what do you mean by query?
OR read values in?
regarding that string value and all, how would that work into my display function? because it works on numbers when it compares to see what the machid is.
sorry didn't see your last post, this is what i mean by query, in access there are tables, queries forms, reports, etc. can u bring values into the VB6 app, from a query or does it all have to be a table?
ahhh....we're getting pretty nosy now aren't we? (GOOD!!)...I don't have the time right now...you'll have to give me a bit....I will then demo the command object which is what you would use and something you have not been exposed to yet. Give me about an hour or so.
ok then i will be able to do that.
Hey Dubya;
I'm stuck on a problem over here and will have to be brief (sorry I cannot spend more time right now - I will check back later this evening)....Another term for Access queries is "Stored Procedure", as basically you are creating a query, and then saving it by name. Other db's like Oracle and SQL Server also support stored procedures but in a much more robust way - they have an actual scripting language you can use to write code - Access however does not support this. So my point here is there really is not anything you can create in an Access query that you cannot do on the fly using ADO and sql. But on ocassion, you need to access a stored query in Access and the command object allows you to do this. Please check out the following link - it has lots of info - plus an example in code that pulls data from an Access stored query.
http://msdn.microsoft.com/library/de...activeconx.asp
cheers
sorry i have been gone, but this is my problem i need to add another form that has fields from 2 of the tables, now i thought that it would be easier to just do a select query in Access that already has the fields in it all i would have to do is open it as a recordset, and then be able to just assign the value from the fields in that Access query to a text box in the VB6 application
Sounds like a good plan, although you have not provided many details. It might be a good idea to start another thread and be more specific with your question. I will still be happy to reply, but because this thread has grown so long - it would probably be beneficial to you to start another one as there will be a much greater chance that additional forum members will reply. You decide - either way - I will reply and help as best I can. cheers.
:thumb: