Results 1 to 2 of 2

Thread: Selecting from a field in a database

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2000
    Location
    Liverpool
    Posts
    1

    Post

    As I am a bit of a novice to VB I need help with the following problem. I have a form to add new members to my membership table in a database. The form contains text boxes that write to the table via a command button. One of the text boxes is for 'Membership Number'. I want this text box to automatically come up with the next available number when I open the form. I'm sure that this is a fairly simple question, but I am new to the subject!

  2. #2
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    Calgary Alberta
    Posts
    359

    Post

    dim rcdTable as recordset, dbsData as database

    set dbsData = opendatabase("database.mdb")
    set rcdtable = dbsdata.openrecordset("select MembreNumber from table")

    rcdtable.movelast
    if rcdtable("MemberNumber") <> "" then
    txtmember.text = cint(rcdtable("MemberNumber")) + 1
    else
    txtmember.text = "1"
    end if
    rcdtable.close
    dbsdata.close

    Here you go, you have to change variable names etc but it works.

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