ADP help passing parameters

Carly

Registered User.
Local time
Today, 16:49
Joined
Apr 16, 2003
Messages
86
I hope I explain this well enough for someone to understand but please bear with me as I am pretty much a novice at this.

I have a query on ADP which is the following SQL Code:
PHP:
SELECT CONVERT(char(10), wcs_entry_date_time, 103) AS Date, LEFT(wcs_container_id, 2) AS Container, COUNT(wcs_container_id) AS [Number of Units Received]
INTO dbo.[tbl A Number of Pallets & Containers Received]
FROM dbo.wcs_mhejrn_stock_received
WHERE (wcs_entry_date_time BETWEEN @EnterDate1 AND @EnterDate2) AND (CONVERT(char(8), wcs_entry_date_time, 108) BETWEEN @EnterTime1 AND @EnterTime2)
GROUP BY CONVERT(char(10), wcs_entry_date_time, 103), DAY(wcs_entry_date_time), MONTH(wcs_entry_date_time), YEAR(wcs_entry_date_time), LEFT(wcs_container_id, 2)
ORDER BY MONTH(wcs_entry_date_time), DAY(wcs_entry_date_time), YEAR(wcs_entry_date_time), LEFT(wcs_container_id, 2)
The following is the Code which I have written to pass the parameters to query:
PHP:
Public Function cmdANoPltsReceived()
DoCmd.SetWarnings False
Dim cnn As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim param1 As ADODB.Parameter, param2 As ADODB.Parameter, param3 As ADODB.Parameter, param4 As ADODB.Parameter
Set cnn = CurrentProject.Connection
Set cmd.ActiveConnection = cnn
cmd.CommandText = "[Qry A Number of Pallets & Containers Received]"
cmd.CommandType = adCmdStoredProc
Set param1 = cmd.CreateParameter("@EnterTime1", adDBTime, adParamInput)    
cmd.Parameters.Append param1    
param1.Value = Null    
param1.Value = [Forms]![Frontpage]![txtTime1]
Set param2 = cmd.CreateParameter("@EnterTime2", adDBTime, adParamInput)    
cmd.Parameters.Append param2    
param2.Value = Null    
param2.Value = [Forms]![Frontpage]![TxtTime2]
Set param3 = cmd.CreateParameter("@EnterDate1", adDBDate, adParamInput)    
cmd.Parameters.Append param3    
param3.Value = Null    
param3.Value = [Forms]![Frontpage]![TxtDate1]
Set param4 = cmd.CreateParameter("@EnterDate2", adDBDate, adParamInput)    
cmd.Parameters.Append param4    
param4.Value = Null    
param4.Value = [Forms]![Frontpage]![TxtDate2]
''CHECKING IF TABLES EXIST''
RefreshDatabaseWindow
If TblExists("tbl A Number of Pallets & Containers Received") Then     DoCmd.RunSQL ("DROP TABLE [tbl A Number of Pallets & Containers Received]")
Else
End If
cmd.Execute
DoCmd.OpenForm "Frm A NoPltsReceived"
End Function
This code passes the Dates fine but not the times. The Date controls on the form "Frontpage" are Short Dates and the Times are Long Times.

Can anyone see what I am doing wrong? Any help would be greatly received.

Kind Regards

Carly
 

Users who are viewing this thread

Back
Top Bottom