I am very new to all of this, but I need some help! Currently I have two forms. These forms are for entering new data into the database. The first form's primary key is the 'Clearance ID' field which has an autonumber format. After all info is filled into the first form then the user is prompted to fill out the second form. This is where I need help.....The second form is referenced to the 'Clearance ID' given in the first form. This second form, 'Tag Info', allows the user to add tag placement information. Right now the 'tag' field is a number field, where the user has to input the tag #, such as 1, 2, 3, 4...... for each record they add. Ultimately I want this field to be auto-populated, starting with 1 and increasing by 1, each time a field is added, within that specific 'Clearance ID'. I've tried the following:
Private Sub Form_OnOpen()
Dim rstTagID As DAO.Recordset
Dim Tag As Long
Set rstTagID = DMax("[Tag]", "Clearance Tag List"
If IsNull(rstTagID) Then
Tag = 1
Else
rstTagID.MoveLast
Tag = rstTagID!Tag + 1
End If
Me.Tag = Nz(DMax("[Tag]", "Clearance Tag List",0) + 1
End Sub
But this doesn't work! Does anyone have a suggestion?
Private Sub Form_OnOpen()
Dim rstTagID As DAO.Recordset
Dim Tag As Long
Set rstTagID = DMax("[Tag]", "Clearance Tag List"
If IsNull(rstTagID) Then
Tag = 1
Else
rstTagID.MoveLast
Tag = rstTagID!Tag + 1
End If
Me.Tag = Nz(DMax("[Tag]", "Clearance Tag List",0) + 1
End Sub
But this doesn't work! Does anyone have a suggestion?