UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Where Works But Then It Does Not - Error 3075, Access 2016    
 
   
jotoya
post Mar 5 2019, 10:04 AM
Post#1



Posts: 137
Joined: 17-May 16



Hello UA folks,

I've got a peculiar problem: Here is my WHERE clause declared as Dim strCriteria As String: "strCriteria = "([ContactDate] >= #" & Me.FromDt & "# And [ContactDate] <= #" & Me.ToDt & "#)"

In a form, a user can elect to enter a "From" and "To" date if they so choose to find specific records for that given date range. If the user leaves the date fields blank, all records are returned. So, when I first load the form and I click the "Search" button *without* using the date fields, all works just fine.

Now, if I enter a date range that is contained within the data, again, records are found just fine. BUT, once I clear the fields by setting them to NULL and then I try to run a search for all records (both date fields being empty), Access throws a 3075 error indicating there is a syntax error iconfused.gif

Doing a Debug.Print strCriteria yields the following:

CODE
([ContactDt] >= #2/12/2019# And [ContactDt] <= #2/12/2019#) 'With dates entered and worked.
([ContactDt] >= ## And [ContactDt] <= ##)  'With date fields set to Null and receiving the 3075 error.


Why would it work when the form loads and the date fields are empty, but, when I use VBA to set the date fields to NULL, all goes South. Any guidance is greatly appreciated.
Go to the top of the page
 
jotoya
post Mar 5 2019, 10:07 AM
Post#2



Posts: 137
Joined: 17-May 16



**NEVER MIND**

I apologize. I should've been more thorough. I thought I had set the fields to NULL when in fact I had set them to: ""

All works well now. Apologies for the inconvenience.
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    23rd August 2019 - 09:36 AM