I have a database with an automatic number entry for the ID. But when the "ADD" button is clicked on my VB app the auto number doesn't appear and you must type it in yourself what can i do?
Please help my time is running out...Thanks
Option Explicit
Dim strString As String
Dim db As Database
Dim rs As Recordset
Dim dbname As String
Private Sub Form_Load()
dbname = App.Path & "\sourcebook"
Set db = OpenDatabase(dbname, False, False)
Set rs = db.OpenRecordset("Select * from source order by id", dbOpenDynaset)
With rs
.MoveFirst
Text1 = !id
Text2 = !DateTime
End With
End Sub
'Text1 = the autonumber ID
'No we take a button to addnew
'button to Addnew
With rs
.AddNew
Text1 = !id
Text2 = ""
Text2.SetFocus
End With
'button to save
With rs
If Not Text2 = "" Then
!DateTime = Text2
.Update
End If
End With
Eric De Decker
vbg.be@vbgroup.nl
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.