Lookup question

C

Chris

I am using a Macro that calls up an append query to move
data from one table to another. The query prompts the user
to 'name' the records. The name is stored in a new field
in the appended table. There can be more than one record
with this 'name', so it is not a primary key.

How can I make the macro check the 'name' field, and if
that 'name' already exists, prompt the user for a new
name?
 
K

Ken Snell

Use a condition expression similar to this to see if the entered name is
already in the table:

Condition: DCount("*", "TableName", "[NameField]='" & InputBox("Enter the
name:") & "'")>0

The above condition will be True if the entered name is already in the
table.

You'd need to then have the macro loop back around to repeat the above step
(after displaying a message box telling the user that this name is already
in the table) so that the user is again prompted for a name.
 

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