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

DStegon via AccessMonster.com

you posted twice so I am copying from the otehr post... you should read that
post because another member made another good point

how about try this...

This assumes that cboxYear is a command button on the form in which this
routine is part of the module.

Private Sub cboxYear_Click()

if MsgBox("Do you want to sum up the Year?", vbYesNo,
"Yes?") = vbYes then
Me.RecordSource = "4QryAdageVolumeSpendYearsum"
End If

End Sub

much cleaner and easier to read and you are not testing the value of an int
but instead the boolean value of your msgbox response.
 

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 0
SendObject Email 2
SendObject code 6
SendObject and combo boxes 1
Trying to remove error from conflicting code 0
Key Press 8
Yes No Message Box 7
new email form in front of MsgBox 1

Top