G
Guest
Hi,
I am trying to count the rows in a table where the date (Update_Archive) is
between two user-input dates on my form, frmWork_Load. However, I get an
error saying that "No Value given for one or more required parameters."
Public Function Calculate_Workload() As String
If ([Forms]![frmWork_Load]![Second_Date]) >
[Forms]![frmWork_Load]![First_Date]
Then DateMessage() As String
Else
'Establish connection to ActiveX Data Objects
Dim trs As ADODB.Connection
Set trs = CurrentProject.Connection
'Declare Recordset
Dim allRecords As New ADODB.Recordset
allRecords.ActiveConnection = trs
'SQL statement to populate Recordset
Dim SQL As String
SQL = "SELECT Count([ARCHIVE].[Invoice_Number]) FROM Archive"
SQL = SQL + " WHERE (ARCHIVE.Update_Archive) BETWEEN "
SQL = SQL + "[Forms]![frmWork_Load]![First_Date]"
SQL = SQL + " AND "
SQL = SQL + "([Forms]![frmWork_Load]![Second_Date])"
'Run SQL Select statement
allRecords.Open SQL
'Retrieve the value from the upper-left most of the Recordset
Forms!frmWork_Load!Result = (allRecords.Fields(0).Value)
'Close Recordset and terminate connection
allRecords.Close
Set allRecords = Nothing
Set trs = Nothing
End If
End Function
I am trying to count the rows in a table where the date (Update_Archive) is
between two user-input dates on my form, frmWork_Load. However, I get an
error saying that "No Value given for one or more required parameters."
Public Function Calculate_Workload() As String
If ([Forms]![frmWork_Load]![Second_Date]) >
[Forms]![frmWork_Load]![First_Date]
Then DateMessage() As String
Else
'Establish connection to ActiveX Data Objects
Dim trs As ADODB.Connection
Set trs = CurrentProject.Connection
'Declare Recordset
Dim allRecords As New ADODB.Recordset
allRecords.ActiveConnection = trs
'SQL statement to populate Recordset
Dim SQL As String
SQL = "SELECT Count([ARCHIVE].[Invoice_Number]) FROM Archive"
SQL = SQL + " WHERE (ARCHIVE.Update_Archive) BETWEEN "
SQL = SQL + "[Forms]![frmWork_Load]![First_Date]"
SQL = SQL + " AND "
SQL = SQL + "([Forms]![frmWork_Load]![Second_Date])"
'Run SQL Select statement
allRecords.Open SQL
'Retrieve the value from the upper-left most of the Recordset
Forms!frmWork_Load!Result = (allRecords.Fields(0).Value)
'Close Recordset and terminate connection
allRecords.Close
Set allRecords = Nothing
Set trs = Nothing
End If
End Function