How to check to a query field when input a value?

G

Gary

Hi,

When I input in a form field , if I want system can check is it have the
same record in a query,
if no, show a message box.

Please help, thank!

Gary
 
S

Steve Schapel

Gary,

Here's one idea, for code on the Before Update event of the control on
the form...

If DCount("*","YrQuery","[YrField]='" & Me.YrField & "'") = 0 Then
MsgBox "YourMessage"
Cancel = True
End If

This example assumes a text data type. If it's a number, the code is
like...

If DCount("*","YrQuery","[YrField]=" & Me.YrField) = 0 Then
MsgBox "YourMessage"
Cancel = True
End If
 
G

Gary

Thank so much!!

Steve Schapel said:
Gary,

Here's one idea, for code on the Before Update event of the control on
the form...

If DCount("*","YrQuery","[YrField]='" & Me.YrField & "'") = 0 Then
MsgBox "YourMessage"
Cancel = True
End If

This example assumes a text data type. If it's a number, the code is
like...

If DCount("*","YrQuery","[YrField]=" & Me.YrField) = 0 Then
MsgBox "YourMessage"
Cancel = True
End If

--
Steve Schapel, Microsoft Access MVP

Hi,

When I input in a form field , if I want system can check is it have the
same record in a query,
if no, show a message box.

Please help, thank!

Gary
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top