-
Help Me Please :D
Good day guys ! :)
I would like to post my problem in vb6. I was creating an Database for our Pharmacy Store, everything is set except for the entry number, i'm using mysql database via access, i just like to get the last ItemNumber of my database, if you understand me please give me some code .
-
Re: Help Me Please :D
If you do a select query and put all records (or all the records you WANT anyway) into a recordset (do you know how to connect to your db and return data?), you simply use something like:
rs.movelast (where rs is the name of your recordset
then to 'get' the last ItemNumber, you'd do something like this
Dim myNum as Long
myNum = rs!ItemNumber
Now, if you are looking for the 'greatest/largest' number only (where the largest ItemNumber may or may not be the last record in your table), you can use the MAX keyword in your query and it will return ONLY that one record. OR, if you use "order by ItemNumber" in your query, you can also get that 'biggest' itemNumber (if you use 'desc' it will be the FIRST record, if you use the default (asc) (default meaning if you don't use it, the query will use it automatically), it will be the LAST record (use rs.movelast)
-
Re: Help Me Please :D
Oops, I see you are using Access as the front end, not VB6....why are you posting it here instead of in the database section?
-
Re: Help Me Please :D
Is that where it would go? I'd have thought it belongs in the Office section.
-
Re: Help Me Please :D
Welcome to VBForums :wave:
As you are using Access as a front-end, the 'VB6' forum is not really apt - while it certainly isn't made clear, the "VB Editor" in Office programs is actually VBA rather than VB, and we have a separate forum for that (Office Development).
However, as your question is a about interaction with MySQL, the 'Database Development' forum is more appropriate, so I have moved this thread there.
-
Re: Help Me Please :D
ow .. thanks for the info .. sorry newbie here ..
and also i tried the rs.movelast earlier and the message in simple word is the program can't read backwards.
-
Re: Help Me Please :D
What do you mean my "last"?
Do you mean the highest in which case you want something like :-
Code:
Select Max(ID)
From MyTable
Do you mean the most recently entered in which case this is probably closer
Code:
Select Top 1(ID)
From MyTable
Order By InputDateAndTime Desc
Or is there some other definition for "Last"?
Generaly I'd steer you away from the MoveLast aproach. That's pulling a large amount of data when you're only actually interested in a single value. It's almost always more efficient to let the database do the work for you.
-
Re: Help Me Please :D
i would like to see what you are doing, table structure and such, but i cannot contact you by private message as your box is too full, you need to tidy up your message space to be able to pass the table examples.