Bob Gajewski
rbgajewski at adelphia.net
Tue Apr 29 20:43:55 CDT 2008
Hello Friends
I am putting together a quick table and form for equipment. The index
consists of two fields: EquipmentTypeCode (which is a two-character text
field) and EquipmentSequence (which is a long integer field).
I have got the code so that after the user selects the type code, the
program will automatically assign the next sequence. This works fine as long
as there is already at least one record for that type code. My problem is
when there is no record for that type code - how do I check for that, so
that I can set the sequence number to 1 ?
I appreciate any suggestions or guidance.
Best regards,
Bob Gajewski
CODE
-----------------------------------------------------------
Private Sub EquipmentTypeCode_AfterUpdate()
EquipmentSequence = DMax("EquipmentSequence", "tblEquipment",
"[EquipmentTypeCode] = '" & EquipmentTypeCode & "'") + 1
If EquipmentSequence < 1 Then
EquipmentSequence = 1
End If
EquipmentSerialNumber.SetFocus
LastUpdated = Date
End Sub
-----------------------------------------------------------
Private Sub EquipmentSequence_AfterUpdate()
LastUpdated = Date
End Sub
-----------------------------------------------------------
Private Sub EquipmentSerialNumber_AfterUpdate()
LastUpdated = Date
End Sub