Log in

View Full Version : Search for visitor,if exists,use data,else,enter?


mmu01891
May 29, 2008, 08:12 AM
When visitor comes,I enter their ID,if he/she exists,I enter a new record for her visit using the details already in the database.

But if he/she does not exist in the database,want to be able to enter his/her details in the visitor s details form and then after that,enter the details of his or her visit in the visitDetails form.

In other words,I have 2 forms,visitDetails which stores details of a visitor s visit such as timeIn,timeOut and natureOfVisit,the other form is visitorDetails which stores information about the visitot such as name,ID,surname,placeOfResidence.

I also have a query which prompts the user to enter the visitor 's ID,if a match is found,I want to be taken to the visitDetails to enter a new visit record for a visitor whose personal details already exist.
And if a match is not found,I want to be taken to the visitorDetails to enter personal details of a visitor and the to the visitDetails form to enter a new visit record for him/her.

Thank for any help!

ScottGem
May 29, 2008, 08:25 AM
In the After Update event of the control where you enter the Visitor ID add code like:

If Not IsNull(DLookup("[VisitorID]","tblVistors"."[VisitorID] = " & Me.txtVisitorID)) Then

DoCmd.OpenForm "frmNewVisit"

Else

Docmd.OpenForm "frmNewVisitor"

End If