Click to See Complete Forum and Search --> : Selecting from a field in a database
howard1 1
Jan 28th, 2000, 12:06 AM
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!
netSurfer
Jan 28th, 2000, 12:11 AM
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.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.