Method or data member not found


New Member
Nov 8, 2004
Greetings all!

I've got a problem I'm hoping someone can help out with.

I've got a series of tables that are archived data by year. For example: MyData_2006, MyData_2007 etc.

Now they all use the same exact form to view and edit the data. So what I'm trying to do is create a drop down box that will change the record source of that form based upon what the user chose. So the user will choose the year from the drop down, push the button and the Form will open up with the record source changed to that year.

The problem I'm running into is when it gets to the recordsource line of code I get the error message: Method or data member not found.

When I searched for this on Google it indicates that I was missing the "Microsoft DAO 3.5 (or 3.6) Object Library". However, I'm NOT missing it. It's in my list of available references and is checked. I've got 3.5 & 3.6 available (I've tried them both, but am using 3.6 by default).

So if anyone has any further ideas, I would greatly appreciate it!


Below is my code:
Private Sub View_Season_Click()

Dim dbs As Database
Set dbs = CurrentDb
strSeason_Value = Me!Combo4.Column(1)
dbs!Forms!Cost_Sheet.RecordSource = strSeason_Value
DoCmd.OpenForm "Cost_Sheet"

End Sub

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
I don't see why this would be caused by a missing reference.

Have you checked all the names of the forms/controls?
Upvote 0
Well, if I'm looking at it right the only things I could misspell would be the form name and the table name that I'm changing the recordsource to?

The form name is Cost_Sheet and the table name is MyData_2007 or MyData_2008.

I've triple checked the spelling everywhere, and they all look good.
Upvote 0
It may help to go to the strSeason_Value = Me!Combo4.Column(1) line in your code and press F9. This will place a red dot to the left of it, this is called a breakpoint. When you try to run your code it will halt when it reaches this line. Then you can check the value of Me!Combo4.Column(1) by hovering over it and ensure that it is the value your expecting.

Upvote 0
What jumped out at me was that it you are trying to reference the form as if it were already open, but I don't think it is (based on reading your request carefully.)

So, you code is like this:
dbs!Forms!Cost_Sheet.RecordSource = strSeason_Value
DoCmd.OpenForm "Cost_Sheet"

dbs!Forms!????? only works for forms that are open.

Reverse those two lines and it should work.
Better yet (in my opinion) would be to drop the dbs!Forms!Cost_... and place that line in the Load event of the Cost_Sheet form. Have that line refer back to the form that opens the Cost_Sheet form to get the value that is in column 1 of your combo box.

Upvote 0
You don't need to use VBA to do this. If the form is based on a query, then the year can be filtered within the query using the criteria :

=Forms![Cost_Sheet].Combo4 or Like Forms![Cost_Sheet].Combo4 Is Null

Hopefully I have the right form and combo box names.....

Upvote 0
Andrew, According to the original spec in the original question, this data HAS BEEN archived into tables and each table holds one year of data. Are you actually suggesting a UNION query that will read ALL the data from ALL the archived tables, just so the year can be filtered by year?

Maybe an explaination would help here.
Upvote 0
Greetings all,

Thanks for the suggestions so far.

Giacoma: I've confirmed that strSeason_Value is giving me the value I'm looking for. I didn't use a break point, but I used a message box to display the value when I clicked the button.

Vic: I added dbs!Forms ... etc while troubleshooting. And I have tried to open the form first. BUT, I forgot to mention that the error "Method or Data member not found" is actually a compile error. So I click the command button and the error immediately comes up.

The code screen comes up and this part of the code is highlighted:
.RecordSource =

So it's acting like it's not recognizing the RecordSource option!

Any other ideas I could try?
Upvote 0
this worked for me...
Dim strSeason_Value As String

strSeason_Value = Me.Combo4.Column(1)
DoCmd.OpenForm "Cost_Sheet"
Forms("Cost_Sheet").RecordSource = strSeason_Value

Notice I flipped the above the recordsource = line. You cannot change the rs unless it's open. Plus no need to reference the DAO objects

Upvote 0

Forum statistics

Latest member

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back