G
Guest
hy
i have a form called marketers and fileds called visittype,first,last and id.
i have following code to generate the autonumber for field id based on
condition of visittype.
if visittype is first visit then only it's supposse to generate the
autonumber else the code is dlooking up a value from database based on the
last and first control of the form.
everything is working fine, but the problem is users select visttype as
first visit and then they choose last and first name from drop down box
instead of writting it down.and this code still generate the new id# for same
first and last name in databse and as a result i have a two id for same name.
is there a way i can modify this code such a way that it looks up at a
visittype as first visit and then looks up at the first and last on the
current form and then if the names are already in databse tabel gives a
massage like this name is already in the database.
thanks for your help
Private Sub doctorid_GotFocus()
Dim DOCTORID As Long
If VISITTYPE = "First Visit" Then
Forms!MARKETERS!DOCTORID = Nz(DMax("[DOCTORID]", "MARKETERS"), 0) + 1
Else: Forms!MARKETERS!DOCTORID = DLookup( _
"[DOCTORID]", "marketers", "MARKETERS.LAST = " & Chr(34 _
) & Forms!MARKETERS.last & Chr(34 _
) & " And MARKETERS.FIRST = " & Chr(34 _
) & Forms!MARKETERS.first & Chr(34))
End If
End
End Sub
i have a form called marketers and fileds called visittype,first,last and id.
i have following code to generate the autonumber for field id based on
condition of visittype.
if visittype is first visit then only it's supposse to generate the
autonumber else the code is dlooking up a value from database based on the
last and first control of the form.
everything is working fine, but the problem is users select visttype as
first visit and then they choose last and first name from drop down box
instead of writting it down.and this code still generate the new id# for same
first and last name in databse and as a result i have a two id for same name.
is there a way i can modify this code such a way that it looks up at a
visittype as first visit and then looks up at the first and last on the
current form and then if the names are already in databse tabel gives a
massage like this name is already in the database.
thanks for your help
Private Sub doctorid_GotFocus()
Dim DOCTORID As Long
If VISITTYPE = "First Visit" Then
Forms!MARKETERS!DOCTORID = Nz(DMax("[DOCTORID]", "MARKETERS"), 0) + 1
Else: Forms!MARKETERS!DOCTORID = DLookup( _
"[DOCTORID]", "marketers", "MARKETERS.LAST = " & Chr(34 _
) & Forms!MARKETERS.last & Chr(34 _
) & " And MARKETERS.FIRST = " & Chr(34 _
) & Forms!MARKETERS.first & Chr(34))
End If
End
End Sub