Match the values with table contents

  • Thread starter Thread starter wasim_sono
  • Start date Start date
W

wasim_sono

I have a table named "Nil-Master" having a string type fiel
named"Customer". Now a new Form is used for data entry. This for
named "Nil-Question" having field named "Customer"
I want that when User enter customer no on form then this custome
first match with "Nil-Master" field "Customer". If yes then forwar
on next field otherwise print a message
For this please provide me a coding

Thanks
 
On the BeforeUpdate event of NilQuestion field Customer
If ISNull("[Customer]", "tblNil-Master", "Customer =
Forms!Nil-Question!Customer) Then
MsgBox "No Match, try again...",vbOK, "Customer Not Found"
Customer.Undo
Cancel = True
End If

But, the best solution is to use a combo box to select the Customer. The
combo would be populated by ONLY legitimate Customers from table Nil-Master,
and if the combo has LimitToList = Yes, then there is no way to enter an
illegitimate Customer in that field.
That's the best way to do it!
hth
Al Camp
 
How to populate the combo box with customer no? will it slow th
processing or data entry? There is about 20,000 customer in custome
field of master table
 
Wasim,
A Combo box derives it's values from a table or query as it's RowSource.
So you would use your Customer data as the RecordSource, probably with
CustomerNo in Col1 and Customer Name in Col2, and set the combos
ControSource to the CustomerNo field on your form.
You'll neeed to study up on combo boxes... how to set them up, and how to
use them. A combo box that only lists legitimate CustomerNos for the user
to select is the best method to prevent invalid data from being entered.
hth
Al Camp
 
Dear Al Cam
Thanx for ur suggestion for combo box. I used it. But there's a littl
bit problem that length of Customer field is 10. If a user enter les
than 10 digit customer no, the form filed accept the current value
of the form filed those are matching with combo box values. I
there's a solution
 
Back
Top