Error when attempting to update recordset property

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

When attempting to update the recordset property of a sub form, I receive
this error message- error umber 2001: you cancelled the previoys operation.
This is the code that generates the error:

Sub Change()
On Error GoTo ErrorHandler

'declare variables for combo box controls on form header
Dim strChildYear As String
Dim strChildCCtr As String
Dim strPlanArea As String
Dim strSQL As String

'assign values to variables
strChildYear = Me!cboYear.Value
strPlanArea = Me!cboPlanArea.Value
strChildCCtr = Me!cboCCtr.Value

If Me!cboCCtr.Value = "Global" Then
Me!cboPlanArea.Visible = True
strSQL = "SELECT tblLbrDataParents.ParentPlanArea,
tblLbrDataChild.ChildId, " & _
"tblLbrDataChild.ParentIdRef,
tblLbrDataChild.ChildDescr, " & _
"tblLbrDataChild.ChildSort,
tblLbrDataChildDetail.ChildCCtr, " & _
"tblLbrDataChildDetail.ChildYear,
tblLbrDataChildDetail.Jan, " & _
"tblLbrDataChildDetail.Feb,
tblLbrDataChildDetail.Mar, " & _
"tblLbrDataChildDetail.Apr,
tblLbrDataChildDetail.May, " & _
"tblLbrDataChildDetail.Jun,
tblLbrDataChildDetail.Jul, " & _
"tblLbrDataChildDetail.Aug,
tblLbrDataChildDetail.Sep, " & _
"tblLbrDataChildDetail.Oct,
tblLbrDataChildDetail.Nov, " & _
"tblLbrDataChildDetail.Dec " & _
"FROM (tblLbrDataParents INNER JOIN tblLbrDataChild ON "
& _
"tblLbrDataParents.ParentId =
tblLbrDataChild.ParentIdRef) " & _
"INNER JOIN tblLbrDataChildDetail ON
tblLbrDataChild.ChildId = " & _
"tblLbrDataChildDetail.ChildRef " & _
"WHERE (((tblLbrDataParents.ParentPlanArea)=" &
strPlanArea & ") AND " & _
"((tblLbrDataChildDetail.ChildCCtr)='" & strChildCCtr &
"') AND " & _
"((tblLbrDataChildDetail.ChildYear)=" & strChildYear &
")); "
Debug.Print strSQL
Me!frmlabour.Form.RecordSource = strSQL
Else
Me!cboPlanArea.Visible = False
End If

Exit Sub

ErrorHandler:
' Display error information.
MsgBox "Error number " & Err.Number & ": " & Err.Description
' Resume with statement following occurrence of error.
Resume Next
End Sub

Any help would be appreciated!

Thank you, in advance.
 
The error was a syntax problem :)

BUT! furthermore, The error message was resolved, but the attempted update
of the recordset was unsuccessful--the sql was not updated in the sub form's
recordset property--no error messages. What did have I done wrong??
 
Back
Top