validating data

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
 
T

Tim Ferguson

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.

Yes: change the workflow. Get your users (1) to look up the person, and (2)
only get the option to set first visit if it's a new person.

Another thing: what happens when you get two different people called "John
Smith"?

Hope that helps


Tim F
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top