Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Comparison

Status
Not open for further replies.

bcoats

Programmer
Jun 20, 2001
49
US
I am trying to use an SQl querry in VBA to obtain the max date from a group of records and then use that to open a form with only the record that had the right ID and Date. I have the correct information but when I use the docmd.OpenForm method in Access and try to use
date = rec!date in the where condition the date won't match even though it exists. I have also tried
date = DateValue(rec!date) this works in the querry engine but I need to be able to pass the Date to the function. What else can I do?? Thank you for you help.

Brian Coats
 
It appears to me that the name of your field is date!
If I am correct you need to rename your field to something else besides date. Date() is reserved for a function and I think that may be where you are running into problems
 
would that matter if the whole thing had to be in quotes anyway like this.

"date = " & DateValue(ThisRec!date)

it is on the end of the openform method like this

docmd.OpenForm &quot;Formname&quot;,,,&quot;<above statement>&quot;

I think it shouldn't but I could be wrong, let me know please, thank you.

Brian Coats
 
I FIGURED IT OUT!!!

In the querry builder of the database I had put date = datevalue(&quot;4/3/01&quot;) but was trying to do in essence date = <returnvalue from datevalue> in the code. When I wrote it like this:

&quot;date = datevalue(&quot;&quot;&quot; & thisrec@date & &quot;&quot;&quot;)&quot; it worked fine. I hope this might help all those out there with a similar problem

Brian Coats
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top