Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Auto number entry

Status
Not open for further replies.

briggsy79

Programmer
Feb 23, 2001
68
SE
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
 
Example :

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

License And Copy Protection AxtiveX.

Download Demo version on my Site:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top