code to change form recordsource

  • Thread starter Thread starter ryan.fitzpatrick3
  • Start date Start date
R

ryan.fitzpatrick3

I would like to change the form's record source, but I get an error on
this code

Private Sub cboxYear_Click()
Dim LResponse As Integer
LResponse = MsgBox("Do you want to sum up the Year?", vbYesNo,
"Yes?")
If LResponse = vbYes Then
Me!frmAlumCans!RecordSource = "4QryAdageVolumeSpendYearsum"
End If
End Sub

It gives me error #2465 saying access can't find field referred in
expression, what does this mean?
 
I would like to change the form's record source, but I get an error on
this code

Private Sub cboxYear_Click()
Dim LResponse As Integer
LResponse = MsgBox("Do you want to sum up the Year?", vbYesNo,
"Yes?")
If LResponse = vbYes Then
Me!frmAlumCans!RecordSource = "4QryAdageVolumeSpendYearsum"
End If
End Sub

It gives me error #2465 saying access can't find field referred in
expression, what does this mean?


Is "frmAlumCans" the name of the form that is running this code, the form
that contains cboxYear? If so, all you want to say to set the recordsource
is this:

Me.RecordSource = "4QryAdageVolumeSpendYearsum"

Or, is "frmAlumCans" the name of a subform on the form that is running the
code? If that is the case, then you would write this:

Me!frmAlumCans.Form.RecordSource = _
"4QryAdageVolumeSpendYearsum"

(That assumes that "frmAlumCans" is the actually name of the subform control
on the main form, which it may not be.)
 
Back
Top