Check if number exits in database from form

  • Thread starter Thread starter Martin Edwards
  • Start date Start date
M

Martin Edwards

Hi

I'm trying to check whether or not a specifik card nr is allready used in
the database.

I have a table called members with two rows called cardnr and name, and a
form named frmmembers with a textbox called card

When writing the cardnr in the form, how is it possible in access to
determine if the cardnr i allready in use?

I have tried the dlookup vba command like this

dlookup("[name]", "members", "[cardnr]=" & form![frmmembers]!card)

That is set to run after every update of the textbox.

Hope you can help

/Martin
 
When writing the cardnr in the form, how is it possible in access to
determine if the cardnr i allready in use?

I have tried the dlookup vba command like this

dlookup("[name]", "members", "[cardnr]=" & form![frmmembers]!card)

That is set to run after every update of the textbox.


You need to run your Dlookup on the BeforeUpdate event:

If not isnull(dlookup("[name]", "members", "[cardnr]=" &
form![frmmembers]!card)) then
msgbox "The cardnumber is allready in use. Pick another."
cancel=true
exit sub
End if


Jesper Fjølner
 
Tak

When writing the cardnr in the form, how is it possible in access to
determine if the cardnr i allready in use?

I have tried the dlookup vba command like this

dlookup("[name]", "members", "[cardnr]=" & form![frmmembers]!card)

That is set to run after every update of the textbox.


You need to run your Dlookup on the BeforeUpdate event:

If not isnull(dlookup("[name]", "members", "[cardnr]=" &
form![frmmembers]!card)) then
msgbox "The cardnumber is allready in use. Pick another."
cancel=true
exit sub
End if


Jesper Fjølner
 
Back
Top