Value Checks

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I need to check the "name value" in Combo Box against an existing "name
value" in a different table to see if they match. If they don't match I want
to display a message and not allow the name to be changed.

ComboBox Name = cboEmp_Name
Control Source = Employees_ID

Table Name = Employees
Field Name = Employees_ID

Thanks in advance

-Simon
 
In the after update event of the combo box put this (assuming ID is numeric)

If IsNull(DLookUp("Employees_ID","Employees","Employees_ID = " &
cboEmp_Name)) then
Msgbox "No Match"
else
Msgbox "It Matches"
end if
 
Hi Dennis,

Thanks a million for the code and it works great, but I'm still in a dilemna
though. The names in the Combo Box are like such:

"Smith, John"
"Baily, Jack"

So, if "Smith, John" is the current record and the user selects "Baily,
Jack" from the Combo what happens is I get two different records with the
same names but with different data elsewhere in the two records.

I'm trying to avoid having duplicate names, but I don't know how to prevent
it using VB. Any suggestions on how to prevent this will be greatly
appreciated.

-Simon
 
Back
Top