Here is the code:
Sub cboClientSelect_AfterUpdate()
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim strSQL As String
Dim frm As Form_SpreadSheet
Dim qdf As DAO.QueryDef
' Find the record that matches the control.
Me.RecordsetClone.FindFirst "[ClientID] = " & Me![cboClientSelect]
Me.Bookmark = Me.RecordsetClone.Bookmark
' Update txtDaysPaid based on record count
Set frm = Form_SpreadSheet
Set dbs = CurrentDb
Set dbsQuery = CurrentDb
' Open QueryDef object (a compiled query in the database named FindActualDays.
Set qdf = dbsQuery.QueryDefs("FindActualDays"
' Refresh QueryDefs collection.
dbs.QueryDefs.Refresh
' Set parameter for the query based on Client entered
' in SpreadSheet form.
qdf.Parameters("Forms!SpreadSheet!cboClientSelect" _
= frm.cboClientSelect
' Open Recordset object (the query). Then count all the records returned.
Set rstQuery = qdf.OpenRecordset()
' Fill or leave Null the field DaysPaid based on the number of records returned.
If rstQuery.RecordCount = 0 Then
frm.txtDaysPaid = Null
Else
frm.txtDaysPaid = rstQuery.RecordCount
End If
rstQuery.Close
Set dbs = Nothing
End Sub
What it is supposed to do is:
fill records on the subform (spreadsub) based on the client selected and fill the text box txtDaysPaid with number of records returned in the query FindActualDays for the client selected.
The error highlights the line:
qdf.Parameters("Forms!SpreadSheet!cboClientSelect" _
= frm.cboClientSelect
telling me that I have not properly identified frm.cboClientSelect, but I have (I think, anyway). Any ideas or advice about what is wrong is appreciated.
Sub cboClientSelect_AfterUpdate()
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim strSQL As String
Dim frm As Form_SpreadSheet
Dim qdf As DAO.QueryDef
' Find the record that matches the control.
Me.RecordsetClone.FindFirst "[ClientID] = " & Me![cboClientSelect]
Me.Bookmark = Me.RecordsetClone.Bookmark
' Update txtDaysPaid based on record count
Set frm = Form_SpreadSheet
Set dbs = CurrentDb
Set dbsQuery = CurrentDb
' Open QueryDef object (a compiled query in the database named FindActualDays.
Set qdf = dbsQuery.QueryDefs("FindActualDays"
' Refresh QueryDefs collection.
dbs.QueryDefs.Refresh
' Set parameter for the query based on Client entered
' in SpreadSheet form.
qdf.Parameters("Forms!SpreadSheet!cboClientSelect" _
= frm.cboClientSelect
' Open Recordset object (the query). Then count all the records returned.
Set rstQuery = qdf.OpenRecordset()
' Fill or leave Null the field DaysPaid based on the number of records returned.
If rstQuery.RecordCount = 0 Then
frm.txtDaysPaid = Null
Else
frm.txtDaysPaid = rstQuery.RecordCount
End If
rstQuery.Close
Set dbs = Nothing
End Sub
What it is supposed to do is:
fill records on the subform (spreadsub) based on the client selected and fill the text box txtDaysPaid with number of records returned in the query FindActualDays for the client selected.
The error highlights the line:
qdf.Parameters("Forms!SpreadSheet!cboClientSelect" _
= frm.cboClientSelect
telling me that I have not properly identified frm.cboClientSelect, but I have (I think, anyway). Any ideas or advice about what is wrong is appreciated.