Duplication of ID

ocp&mcsd

The Hitman
Local time
Today, 12:30
Joined
Jan 25, 2006
Messages
113
Hi all,
How r u?
I have a form with textboxes and a button.
Under this button I have a code to insert the date from the textboxex to a table.
One of these textboxes is an ID.
I want the code to check whther the ID exist in that table, and if yes to insert it.
This ID is not a primary key.

Kindly, try to help me.
 
You could use a dlookup() function to see if it exists before you run the insert code. Would this work?

(Kind of late at night to be hacking out there isn't it? :) )
 
Do you mean something like this:

if me.ID = DLookup(''[CheckID]", "[Checks]") then
insert....
else
msgbox...

??
 
Kind of... Hang on a sec and I'll post you a sample.
 
Providing checkID is a numeric data type
Code:
if (Dcount("[CheckID]", "[Checks]", "[CheckID] = "& Forms![myFormName]!CheckId) <> 0 Then
If it is a string:
Code:
if (Dcount("[CheckID]", "[Checks]", "[CheckID] = '"& Forms![myFormName]!CheckId & "'") <> 0 Then
Does this work?
 
You're welcome sunshine - (?) :p

Did you get it to work?
 

Users who are viewing this thread

Back
Top Bottom