Help | Site Map
Connecting Tech Pros Worldwide
Reply
 
LinkBack Thread Tools
  #1  
Old August 28th, 2008, 07:01 PM
Newbie
 
Join Date: Aug 2008
Posts: 3
Default Run Time Error 3075

I have a form that I want to show invoices in a date range. When clicking on the button I get the following error:

Run Time Error 3075 Syntax error (missing operator) in query expression '(Invoice Date Between #08/27/2008 And #08/27/2008#)'

Here is the code associated w/the error:

Dim strReport As String 'Name of report to open.
Dim strField As String 'Name of your date field.
Dim strWhere As String 'Where condition for OpenReport.
Const conDateFormat = "\#mm\/dd\/yyyy\#"

strReport = "SDInvoice"
strField = "Invoice Date"

If IsNull(Me.txtStartDate) Then
If Not IsNull(Me.txtEndDate) Then 'End date, but no start.
strWhere = strField & " <= " & Format(Me.txtEndDate, conDateFormat)
End If
Else
If IsNull(Me.txtEndDate) Then 'Start date, but no End.
strWhere = strField & " >= " & Format(Me.txtStartDate, conDateFormat)
Else 'Both start and end dates.
strWhere = strField & " Between " & Format(Me.txtStartDate, conDateFormat) _
& " And " & Format(Me.txtEndDate, conDateFormat)
End If
End If

' Debug.Print strWhere 'For debugging purposes only.
DoCmd.OpenReport strReport, acViewPreview, , strWhere

What am I missing?
Reply
  #2  
Old August 29th, 2008, 08:17 AM
QVeen72's Avatar
Moderator
 
Join Date: Oct 2006
Location: Bangalore
Posts: 1,292
Default

Hi,

After building the Where Condition,
Closing "#" for From date is missing..
#08/27/2008 And #08/27/2008#

Keep a BreakPoint at the beginning and check..

REgards
Veena
Reply
  #3  
Old August 29th, 2008, 08:20 AM
QVeen72's Avatar
Moderator
 
Join Date: Oct 2006
Location: Bangalore
Posts: 1,292
Default

Hi,

I guess, there is one more problem...

Your field name is "Invoice Date"
there is a Space in the field name, so you need to Enclose Between
SQUARE BRACKETS

Expand|Select|Wrap|Line Numbers
  1. "Select * From MyTable Where [Invoice Date] Between #08-08-2008#  And #08-08-2008#"
  2.  
Regards
Veena
Reply
  #4  
Old September 2nd, 2008, 03:22 PM
Newbie
 
Join Date: Aug 2008
Posts: 3
Default

Thanks for you reply. I have reworked the strWhere condition but now receive a "Run-time error 2427. You have entered an expression that has no value" and moves to the VBA code I have set in the "SDInvoice" report, and cannot figure out why? Any insight would appreciated.
Reply
  #5  
Old September 3rd, 2008, 11:41 AM
Member
 
Join Date: Aug 2008
Location: Sao Paulo - Brasil
Age: 52
Posts: 75
Default

Helo,

I think your problem is the Text mising in the text component.

strWhere = strField & " Between " & Format(Me.txtStartDate, conDateFormat) _
& " And " & Format(Me.txtEndDate, conDateFormat)


If Me.txtSTartDate is refered to a textbox you need to add .Text like this

me.txtStartDate.Text and the same at me.txtEndDate.Text

I hope this help
Reply
  #6  
Old September 3rd, 2008, 01:04 PM
Newbie
 
Join Date: Aug 2008
Posts: 3
Default

That did it, thanks to everyone for all your help!
Reply
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles