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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GoToRecord Type Mismatch On Date Criteria

Status
Not open for further replies.

OrWolf

MIS
Mar 19, 2001
291
Hi all,
I have a very simple for with two fields; WeekDate (data type of date/time) and OrderCount (with a data type of number). When I attempt to open the form to the current week's date I get error 13 type mismatch. The field in my table has a format of short date and the field on the form has a format of short date. The open code is below and it's erroring on the GoToRecord statement. I removed all of my custom code to find the current dates end of week date and just hard coded the value to help debug, but the error continues.

strLinkCriteria = "WeekDate = #11/12/2005#"

strDocName = "MyForm"
DoCmd.GoToRecord acDataForm, strDocName, strLinkCriteria


Any ideas?
 
Consider using format function on your table field before comparing to literial within # # delimiters - something like this:
strLinkCriteria = "Format(WeekDate,"Short Date") = #11/12/2005#"
You may need to change the 2005 to 05 if that is Short Date format - I haven't looked. I don't work with dates much. But this is input.
Jeff


 
That still resulted in the same error, however it led me to try something else. I changed my critera to "OrderCount = 1" and I still got the mismatch error. Could there be something else that I'm missing. When I debug the values are as follows:

acDataForm = 2
strDocName = "MyForm"
strLinkCriteria = "OrderCount = 1
 
I found the solution. Rather than using DoCmd.GoToRecord I need to use Me.Recordset.FindFirst with my criteria.

Me.Recordset.FindFirst strLinkCriteria

Thanks for all that looked into this.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top