View Single Post
  #2 (permalink)  
Old September 21st, 2011, 02:47 PM
gjgriffith's Avatar
gjgriffith gjgriffith is offline
Wrox Author
Points: 517, Level: 8
Points: 517, Level: 8 Points: 517, Level: 8 Points: 517, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jul 2009
Location: Boulder, CO
Posts: 110
Thanks: 5
Thanked 14 Times in 14 Posts
Default Did you check the Record Source?

Hello dpm1057,

Thank you so much for posting your question in the "Access 2007 VBA Programmer's Reference" book forum. You asked:

When I choose a date or if I choose <all>, I get an error message:
25880: The record source ' WHERE tblWorkPlans.Target_Go_Live = #5/28/2012# ' specified on this form or report does not exist.
Any thoughts on what could be wrong here?
So, I think I see the answer to your problem. You set the value for the where clause that you are going to replace to NULL in your code that you've provided here:

varWhereClause = Null
strAND = " AND "

If cobFilGoLive <> #1/1/1900# Then
    varWhereClause = (varWhereClause + strAND) & _
    "tblWorkPlans.Target_Go_Live = #" & cobFilGoLive & "#"
End If
In the above code, first you set the "varWhereClause" variable to Null and then you concatenate the Null to the " AND " clause, in the line of code that says:

    varWhereClause = (varWhereClause + strAND) & _
    "tblWorkPlans.Target_Go_Live = #" & cobFilGoLive & "#"
which would be invalid for the WHERE clause. Does that make sense? Hopefully you can understand the problem here, because it looks like you've created an invalid WHERE clause.

Also, my question to you is: Does this error appear in the Access 2007 VBA Programmer's Reference? If so, could you let me know the location in the book (i.e. the page number)? And thanks again for posting your questions!

Geoffrey L. Griffith

Wrox Author of:
Microsoft Access 2010 24-Hour Trainer
Access 2010 Programmer's Reference
Access 2007 VBA Programmer's Reference

*** Please click the THANKS button (to the right) if this post helped you! *** ---------------------------------------------------------------------------------------------------------->