Surname Database

surname database
my database using access 2007,want to be able to search for visitor,if exists,use existing record,if not,enter

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!

Yes you can do that. I assume that you have two recordsets named visitDetails and visitorDetails. And you input visitor id into a textbox called txtId. Let see if this one work. I’m not sure how it is done with Access 2007. But I’m using Visual Basic to talk to MS Access. I think the concept maybe the same.

‘ Assume I have rsVisitor as the object that point at the visitorDetails recordset
‘Move to the first record
‘ Then you find the ID in the
rsVisitor.Find “ID = ‘” & txtID.text & “‘”

‘ The function FIND above will go from row to row to compare the ID string that you input and what exists inside the database. If it is exist the current position of the recordset is at the row that hold the ID. If not it will be End Of File

if rsVisitor.EOF then
‘ Not exist
‘ Exist
end if

Hope this will help

SQL Database Design in 11 minutes, part 1