Enter record if doesn't exist (1 Viewer)

Pavczech

Registered User.
Local time
Today, 20:24
Joined
Jul 11, 2012
Messages
41
Hello

Could somebody help me.

I have 2 tables. First called "Details" with visitors details and Second called "Visits" with visit deatail.

There is the Form where I put all the datails. ( Name, address, Company, Date, Time )

I need the the code which will search the the "Details" table if the record exists.
If it exists it puts ( Date, Time ) to the realated "Visit" table.
If it doesn't it puts all the details ( Name, address, Company ) On to "Details" table and ( Date, Time ) to the realated "Visit" table.

I have tried Dlookup but it seems to require more knowledge than I have.
I am really stuck with it.

Thanks very much for any kind of Help
 

clive2002

Registered User.
Local time
Today, 20:24
Joined
Apr 21, 2002
Messages
91
I Presume the form being used for entry is not bound to either table.

If you need to do unbound then:
I would suggest you create a temp table and use an append query to add to the detail table if the record does not already exist, then run an update query to update the visits table with the date and time.

Then you can run a delete query to remove the record from the temp table.

A better approach would be to create a form bound to details table with a subform showing the multiple related visits at the bottom, this could be used for both review and data entry.

Clive
 

Users who are viewing this thread

Top Bottom