By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,262 Members | 2,664 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,262 IT Pros & Developers. It's quick & easy.

Problem with unbound form fields for search / building query in VBA

P: 3
Hi, I am using unbound text boxes in the header of a form to allow the user to search on a number of fields. I am using VBA to build a query string based on these and it has been fine when comparing text fields on the main form but I have run in to trouble comparing date/time fields on a subform.
The subform is called Activity and I am comparing to the date/time field ActivityStartDate.

This is the code:
Expand|Select|Wrap|Line Numbers
  1. If Not IsNull(Me.searchFromDate) Then
  2.         varFromDate = Format(Me.searchFromDate, "mm/dd/yyyy hh:nn:ss")
  3.         strWhere = strWhere & "([Activity].Form![ActivityStartDate] >= " & varFromDate & ") AND "
  4.         End If
  5.  
(There is code later on to remove the trailing AND if it is at the end)

This gives me the error:
Run-time error 3075 Syntax error (missing operator) in query expression
'([Activity].Form![ActivityStartDate] >= 02/12/2008 00:00:00)'

I've tried printing ActivityStartDate and it's exactly the same date and format.
As the operator does seem to be there I can't see why I get this error message - can anyone shed any light?

Using Access 2007 on Windows Vista.

Thanks in advance
Craig
Mar 11 '08 #1
Share this Question
Share on Google+
1 Reply


P: 3
Sorry, just needed to format the date fields with the # (hash) symbols either side. Noob mistake, my bad.
Mar 13 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.