Hi Everyone,
I am using Access 2003 to input 2 dates from text boxes to display a report. The following is the code I'm trying to run: -
-
Dim fromDate As Date
-
Dim toDate As Date
-
Dim BusProgIDs As String
-
Dim IncAllOpen As Boolean
-
Dim strWhere As String
-
Dim ctl As control
-
Dim i As Integer
-
-
If ckAllOpen.Value = True Then
-
IncAllOpen = True
-
Else
-
IncAllOpen = False
-
End If
-
-
If lstBusinessProgramsPF.ListIndex > 0 Then
-
-
Set ctl = lstBusinessProgramsPF
-
-
fromDate = Format(txtFromProdFail.Value, "mm/dd/yyyy")
-
toDate = Format(txtToProdDate.Value, "mm/dd/yyyy")
-
BusProgIDs = GetSqlBusinessProgram(ctl)
-
-
strWhere = ""
-
strWhere = strWhere & BusProgIDs
-
strWhere = strWhere & " AND CAConfirmationDate BETWEEN #" & fromDate & "# AND #" & toDate & "#"
-
If IncAllOpen = True Then
-
strWhere = strWhere & " OR (" & BusProgIDs
-
-
strWhere = strWhere & " AND (CAConfirmationDate Is NULL)"
-
strWhere = strWhere & " AND (OpeningDate <= #" & toDate & "#))"
-
End If
-
-
DoCmd.OpenReport "ProgressReport", acViewPreview, , strWhere, , (fromDate & "," & toDate)
-
Else
-
MsgBox "One or more Business Programs must be selected to view a report.", vbOKOnly
-
End If
-
However, when I attempt to run it it gives me this error:
syntax error(missing operator) in query expression '(AND CAConfirmationDate BETWEEN #12/12/2000# AND #12/12/2005
Anyone have any idea what would work? Thanks
-Todd
8 1546
Hi Todd
What is this function doing.. -
BusProgIDs = GetSqlBusinessProgram(ctl)
Hi Todd
What is this function doing.. -
BusProgIDs = GetSqlBusinessProgram(ctl)
This function searches through a list box in order to place each ID of each record into the report.
This function searches through a list box in order to place each ID of each record into the report.
But it's adding it to the where criteria in the code.
But it's adding it to the where criteria in the code.
It places the control from the list box into the seperate function -
Private Function GetSqlBusinessProgram(lstControl As control) As String
-
On Error GoTo GetSqlBusinessProgramError
-
-
Dim sqlBP As String
-
Dim i As Integer
-
-
For i = 0 To lstControl.Items.Count - 1
-
If Len(sqlBP) > 0 Then
-
sqlBP = sqlBP & ","
-
End If
-
sqlBP = sqlBP & lstControl.ItemData(lstControl.Items(i))
-
Next
-
sqlBP = "BusinessProgramID IN(" & sqlBP & ")"
-
GetSqlBusinessProgram = sqlBP
-
-
ExitSqlBusinessPrograms:
-
Exit Function
-
-
GetSqlBusinessProgramError:
-
MsgBox Err.Description, vbOKOnly
-
Err.Clear
-
Resume ExitSqlBusinessPrograms
-
-
End Function
OK it looks like the problem is in the use of brackets. Try this ... -
-
Dim fromDate As Date
-
Dim toDate As Date
-
Dim BusProgIDs As String
-
Dim IncAllOpen As Boolean
-
Dim strWhere As String
-
Dim ctl As control
-
Dim i As Integer
-
-
If ckAllOpen.Value = True Then
-
IncAllOpen = True
-
Else
-
IncAllOpen = False
-
End If
-
-
If lstBusinessProgramsPF.ListIndex > 0 Then
-
-
Set ctl = lstBusinessProgramsPF
-
-
fromDate = Format(txtFromProdFail.Value, "mm/dd/yyyy")
-
toDate = Format(txtToProdDate.Value, "mm/dd/yyyy")
-
BusProgIDs = GetSqlBusinessProgram(ctl)
-
-
strWhere = "("
-
strWhere = strWhere & BusProgIDs
-
strWhere = strWhere & " AND (CAConfirmationDate BETWEEN #" & fromDate & "# AND #" & toDate & "#))"
-
If IncAllOpen = True Then
-
strWhere = strWhere & " OR (" & BusProgIDs
-
-
strWhere = strWhere & " AND (CAConfirmationDate Is NULL)"
-
strWhere = strWhere & " AND (OpeningDate <= #" & toDate & "#))"
-
End If
-
-
DoCmd.OpenReport "ProgressReport", acViewPreview, , strWhere, , (fromDate & "," & toDate)
-
Else
-
MsgBox "One or more Business Programs must be selected to view a report.", vbOKOnly
-
End If
-
Mary
OK it looks like the problem is in the use of brackets. Try this ... -
-
Dim fromDate As Date
-
Dim toDate As Date
-
Dim BusProgIDs As String
-
Dim IncAllOpen As Boolean
-
Dim strWhere As String
-
Dim ctl As control
-
Dim i As Integer
-
-
If ckAllOpen.Value = True Then
-
IncAllOpen = True
-
Else
-
IncAllOpen = False
-
End If
-
-
If lstBusinessProgramsPF.ListIndex > 0 Then
-
-
Set ctl = lstBusinessProgramsPF
-
-
fromDate = Format(txtFromProdFail.Value, "mm/dd/yyyy")
-
toDate = Format(txtToProdDate.Value, "mm/dd/yyyy")
-
BusProgIDs = GetSqlBusinessProgram(ctl)
-
-
strWhere = "("
-
strWhere = strWhere & BusProgIDs
-
strWhere = strWhere & " AND (CAConfirmationDate BETWEEN #" & fromDate & "# AND #" & toDate & "#))"
-
If IncAllOpen = True Then
-
strWhere = strWhere & " OR (" & BusProgIDs
-
-
strWhere = strWhere & " AND (CAConfirmationDate Is NULL)"
-
strWhere = strWhere & " AND (OpeningDate <= #" & toDate & "#))"
-
End If
-
-
DoCmd.OpenReport "ProgressReport", acViewPreview, , strWhere, , (fromDate & "," & toDate)
-
Else
-
MsgBox "One or more Business Programs must be selected to view a report.", vbOKOnly
-
End If
-
Mary
Hi Mary,
It gace me the same error. I think my problem is with the function that this function calls, the GetsqlBusinessProgram maybe?
Hi Mary,
It gace me the same error. I think my problem is with the function that this function calls, the GetsqlBusinessProgram maybe?
You need to see what's actually in the criteria.
Put
before the open report command and open the immediate window to see what's being printed
Then copy and paste it here.
Mary
NeoPa 32,556
Expert Mod 16PB
Don't forget to use Copy / Paste Todd.
Your first post was obviously not done using the clipboard (there were typos in it) so it was devoid of most of its information.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Sakke |
last post by:
Hello!
We have written a GCryptoSvr.dll COM server in C++. Inside that resides
WebClient COM component. WebClient CLSID is
{8DC27D48-F94C-434B-A509-C3E1A3E75B9E}. When we are using that...
|
by: jimmyfo |
last post by:
Hi, I recently wrote an ASP.Net web application in VS2005 and published
(using VS2005 Publish feature) it to a relatively clean machine with
ASP.Net 2.0 and MDAC 2.8 installed on it. However, when...
|
by: tito |
last post by:
In my program i am trying to retrieve 'date' field from an excel sheet .This data is inserted into a My SQL Database.The default format for 'date ' field for Excel sheet is in the form of...
|
by: stuck1512 |
last post by:
hi,
i was writing an apache module & successful in retrieving archived files from a folder. i compared all file properties before retrieving but the problem is now i have to retrieve them as...
|
by: fniles |
last post by:
On my machine in the office I change the computer setting to English (UK) so
the date format is dd/mm/yyyy instead of mm/dd/yyyy for US.
This problem happens in either Access or SQL Server.
In the...
|
by: Martin |
last post by:
I'm retrieving some records from a database. One of the fields
contains a date/time. I would like to format it as I send it out to
the table in the displayed page.
Can some one please tell me...
|
by: Geoff Cox |
last post by:
Hello,
at the moment I can add the combined date and time into MySQL using
php
$dt1 = date("Y-m-d H:i:s");
is it possible to add the date and time separately?
I thought it might be
|
by: teo |
last post by:
I'm developing a software (a WinApp, not a WebApp)
to retrieve Date & Time from a web server,
but firstly I need to to test it on my PC, with "localhost"
I'm using the VB Net language
(below...
|
by: Bruno Vignola |
last post by:
Good Morning all,
I need to interoperate with the Calendar of MS Outlook 2003
(inserting, retrieving,
listing events, etc. etc.) from an ASP.NET application; I first
developed a simple
windows...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |