Results 1 to 14 of 14

Thread: [RESOLVED] Number loop

  1. #1

    Thread Starter
    Hyperactive Member Condomx's Avatar
    Join Date
    Dec 2009
    Location
    Iligan City,Philippines
    Posts
    327

    Resolved [RESOLVED] Number loop

    i want to loop the number like from 1 to 3 to 4 and so on if ever i save another record in the ms access,if its detect that there are no record in the ms access then it will show 1 which is ready to the new record and if its detected that there is a record then it should loop ex:there are 2 record in the ms access then it should be loop to 3 and so on..like if its detected that there are number-5 in the last record and the number-2 is deleted so it will be(number-1,number-3,number-4,number-5) then it will loop to 6..

    any help will be appreciated
    ~[L!f3 !s @ll @ab0ut l3@rn!ng]~

    ~*D0nt Give up, h0pe is always present*~

  2. #2

  3. #3
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: Number loop

    Quote Originally Posted by MartinLiss View Post
    I'm sorry but I don't understand.
    Me too....

    @Condomx: If you are asking about unique numbers for your records in MS Access table, then try the AutoNumber type field. For more info, check the help file of MS Access.....

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  4. #4

    Thread Starter
    Hyperactive Member Condomx's Avatar
    Join Date
    Dec 2009
    Location
    Iligan City,Philippines
    Posts
    327

    Re: Number loop

    oh ya i see..so here more details:

    assume that i have a program which as a listview,add button(saving new record),delete button,edit button(update the record) and label1(Student-no<--this one will went to the next number if it is detected the number in the ms access like there is 1 in the ms access record set therefore it will went 2 and so on)...

    O_O
    ~[L!f3 !s @ll @ab0ut l3@rn!ng]~

    ~*D0nt Give up, h0pe is always present*~

  5. #5
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Number loop

    You need to query the DataBase and see how many records there are. You can then use that value as the upper bound.

    Have a search for "rst.MoveNext" for some ball park examples.

  6. #6
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: Number loop

    Or,
    You can store the last StudentID into somewhere(say, Settings table) and when you want to add new record(ie. new student), retrieve the last StudentID that we have stored in the Settings table, increment it's value by one, then display this value in the Label(or whatever you wish)....
    When the new student details are saved into database, change the last studentID (in settings table) to the newly incremented one...! ...

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  7. #7

    Thread Starter
    Hyperactive Member Condomx's Avatar
    Join Date
    Dec 2009
    Location
    Iligan City,Philippines
    Posts
    327

    Re: Number loop

    i mean autonumber in access..how to do that?
    ~[L!f3 !s @ll @ab0ut l3@rn!ng]~

    ~*D0nt Give up, h0pe is always present*~

  8. #8
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Number loop

    You set that field's (within Access) Data Type to "AutoNumber".


    BTW,
    i mean autonumber in access..how to do that?
    isn't even close to your original post!

  9. #9

    Thread Starter
    Hyperactive Member Condomx's Avatar
    Join Date
    Dec 2009
    Location
    Iligan City,Philippines
    Posts
    327

    Re: Number loop

    oh...THANK YOU..
    ~[L!f3 !s @ll @ab0ut l3@rn!ng]~

    ~*D0nt Give up, h0pe is always present*~

  10. #10
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Number loop

    If your questions has been answered then you can now help us, by marking the thread Resolved. (see my signature block for directions).

  11. #11

    Thread Starter
    Hyperactive Member Condomx's Avatar
    Join Date
    Dec 2009
    Location
    Iligan City,Philippines
    Posts
    327

    Re: Number loop

    i have the code below but the problem is when the ms access table is empty an annoying error occured like "type dismatch"

    Code:
    connection
    rs.Open "configuration", con, 3, 3
                If rs.RecordCount <> 0 Then
                    rs.MoveLast
                        setno = Right((rs("confignumber")), 4)
                        setno = Format(setno) + 1
                        setno.Caption = "configuration" & "-" & setno
                    Else
                        setno.Caption = "configuration" & "-" & 0
                    End If
            rs.Close: Set rs = Nothing
            con.Close: Set con = Nothing
    if anyone out there knows how to fix this then please help me..im getting screw in this..
    ~[L!f3 !s @ll @ab0ut l3@rn!ng]~

    ~*D0nt Give up, h0pe is always present*~

  12. #12
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Number loop

    Test for no records
    Code:
    rs.Open "configuration", con, 3, 3
    If rs.EOF = False Then ' else no records
      ... do your stuff
    End If
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  13. #13

    Thread Starter
    Hyperactive Member Condomx's Avatar
    Join Date
    Dec 2009
    Location
    Iligan City,Philippines
    Posts
    327

    Re: Number loop

    na not working.. :-(
    ~[L!f3 !s @ll @ab0ut l3@rn!ng]~

    ~*D0nt Give up, h0pe is always present*~

  14. #14

    Thread Starter
    Hyperactive Member Condomx's Avatar
    Join Date
    Dec 2009
    Location
    Iligan City,Philippines
    Posts
    327

    Re: Number loop

    oh thanks god my problem is solved in a big help of LaVolpe post...ty dude
    ~[L!f3 !s @ll @ab0ut l3@rn!ng]~

    ~*D0nt Give up, h0pe is always present*~

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