code to change form recordsource

  • Thread starter ryan.fitzpatrick3
  • 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?
 
D

Dirk Goldgar

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.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

SendObject Email 2
SendObject code 6
Key Press 8
Yes No Message Box 7
new email form in front of MsgBox 1
I am beginner 0
add record in combo 6
Changing a Subreport's Recordsource via a Form 1

Top