Results 1 to 8 of 8

Thread: Help Me Please :D

  1. #1

    Thread Starter
    New Member jvrsystems17's Avatar
    Join Date
    Dec 2013
    Posts
    2

    Exclamation 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 .

  2. #2
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,126

    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)

  3. #3
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,126

    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?

  4. #4
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Help Me Please :D

    Is that where it would go? I'd have thought it belongs in the Office section.

  5. #5
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,927

    Re: Help Me Please :D

    Welcome to VBForums

    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.

  6. #6

    Thread Starter
    New Member jvrsystems17's Avatar
    Join Date
    Dec 2013
    Posts
    2

    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.

  7. #7
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,900

    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.
    The best argument against democracy is a five minute conversation with the average voter - Winston Churchill

    Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd

  8. #8
    Frenzied Member
    Join Date
    Nov 2010
    Posts
    1,470

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width