LookUp and compair

  • Thread starter Stephen sjw_ost
  • Start date
S

Stephen sjw_ost

How could I write code that will compair the date I've entered into a Textbox
to the results of dates found in a query?

The query, q_Dates, is using unique values so I am only showing single dates
in the query reuslts. I want my code to see if the date I've entered in my
forms Textbox matches any of the dates found in the query. If it does, stop
the code and if it does not, continue with the code.

Please help, this is driving me nuts...
 
J

Jack Leach

A few weeks ago fellow poster turned me on to a neat little trick to do just
this. Use DLookup to search the query for the value you entered, and returns
Null if not found:

If IsNull(DLookup("fieldname", _
"queryname", _
"[datefield] = #" & Me.Textbox & "#")) Then _
'Returned Null - no matching record
Else
'Returned a value, theres a matching record
End If


(use #date# for date comparisons instead of the usual " for strings)


hth
--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)
 
S

Stephen sjw_ost

Jack, thank you! This works perfectly!
--
Stephen


Jack Leach said:
A few weeks ago fellow poster turned me on to a neat little trick to do just
this. Use DLookup to search the query for the value you entered, and returns
Null if not found:

If IsNull(DLookup("fieldname", _
"queryname", _
"[datefield] = #" & Me.Textbox & "#")) Then _
'Returned Null - no matching record
Else
'Returned a value, theres a matching record
End If


(use #date# for date comparisons instead of the usual " for strings)


hth
--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)



Stephen sjw_ost said:
How could I write code that will compair the date I've entered into a Textbox
to the results of dates found in a query?

The query, q_Dates, is using unique values so I am only showing single dates
in the query reuslts. I want my code to see if the date I've entered in my
forms Textbox matches any of the dates found in the query. If it does, stop
the code and if it does not, continue with the code.

Please help, this is driving me nuts...
 

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