check whether that data is in the table

  • Thread starter Thread starter EMILYTAN
  • Start date Start date
E

EMILYTAN

I want to check whether that data entered is in that table or not in MS
ACCESS...
I am using MS ACCESS to create my application....
May i know the way?
 
Hi Allen,
Can I know how to write the code when i click a button, it will auto check
whether that data is there, if there is, it will prompt a message "valid"
else "invalid".......?
 
Yes: you can do that in the BeforeUpdate event procedure of your form.

We can't write your code for you, so if you don't know anything about
writing code, you will have some learning to do to get there.
 
I wrote this code:-

InRemarks.SetFocus
Result = DLookup("[JobNumber]", "OpenJob", "[JobNumber] = " &
InRemarks.Text)
MsgBox Result

I briefly explain how it flow. I will key in the job number in the InRemarks.
Text and when i click a button, it should be able to display the result that
has the record...
However, when i key in the job number it turn to be an error display data
type mismatch criteria expression and when i key in alpha numeric it display
you cancelled previous operations....
Why?

Allen said:
Yes: you can do that in the BeforeUpdate event procedure of your form.

We can't write your code for you, so if you don't know anything about
writing code, you will have some learning to do to get there.
Hi Allen,
Can I know how to write the code when i click a button, it will auto check
[quoted text clipped - 12 lines]
 
If you open the OpenJob table in design view, what data type is the
JobNumber field?

If Text, try:
Dim strWhere As String
Dim varResult as Variant
strWhere = "[JobNumber] = """ & Me.InRemarks & """"
varResult = DLookup("[JobNumber]", "OpenJob", strWhere)
MsgBox "Searched where " & strWhere & vbCrLf & _
"Result: " & varResult

If the field is a Number type, change line 3 to:
strWhere = "[JobNumber] = " & Nz(Me.InRemarks,0)

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

EMILYTAN via AccessMonster.com said:
I wrote this code:-

InRemarks.SetFocus
Result = DLookup("[JobNumber]", "OpenJob", "[JobNumber] = " &
InRemarks.Text)
MsgBox Result

I briefly explain how it flow. I will key in the job number in the
InRemarks.
Text and when i click a button, it should be able to display the result
that
has the record...
However, when i key in the job number it turn to be an error display data
type mismatch criteria expression and when i key in alpha numeric it
display
you cancelled previous operations....
Why?

Allen said:
Yes: you can do that in the BeforeUpdate event procedure of your form.

We can't write your code for you, so if you don't know anything about
writing code, you will have some learning to do to get there.
Hi Allen,
Can I know how to write the code when i click a button, it will auto
check
[quoted text clipped - 12 lines]
I am using MS ACCESS to create my application....
May i know the way?
 
OH THANK YOU! It can work already! Thanks for helping!

Allen said:
If you open the OpenJob table in design view, what data type is the
JobNumber field?

If Text, try:
Dim strWhere As String
Dim varResult as Variant
strWhere = "[JobNumber] = """ & Me.InRemarks & """"
varResult = DLookup("[JobNumber]", "OpenJob", strWhere)
MsgBox "Searched where " & strWhere & vbCrLf & _
"Result: " & varResult

If the field is a Number type, change line 3 to:
strWhere = "[JobNumber] = " & Nz(Me.InRemarks,0)
I wrote this code:-
[quoted text clipped - 25 lines]
 
Back
Top