Match a vlue with table field

  • Thread starter Wasim Yasin via AccessMonster.com
  • Start date
W

Wasim Yasin via AccessMonster.com

I have a table name 'MasterTable'. when a user inputs data in a field on
the form , at this stage i want the values be entered first match with
master table field. If matched then proceed on next field otherwise display
amessage.For this purpose I need code of event procedure.
 
O

Ofer

If i understood you then on the before update of your field you shoul enter
he code

if isnull(dlookup("FieldName", "MainTable","MyFieldInTable="
Me.fieldinform") then
msgbox "NotFound"
cancel=true
endif
 
W

Wasim Yasin via AccessMonster.com

I entered the same code but there is a run time error. my details of query
is as follow:

master table name : Nil-Master
master table field name : Customer

Form name: Nil-Question
Form field name: Customer

Now please provide a true or error free syntax. I'll be very thankful to u.
God bless u.
 
O

Ofer

try

'if the field Customer type is string
if isnull(dlookup("Customer", "[Nil-Master]","Customer='" & Me.Customer &
"'") then
msgbox "NotFound"
cancel=true
endif

'if the field Customer type is Number
if isnull(dlookup("Customer", "[Nil-Master]","Customer=" & Me.Customer) then
msgbox "NotFound"
cancel=true
endif
 
W

Wasim Yasin via AccessMonster.com

the field type is string. I tried for string code but still there is a run
time error 3464.
 
Top