Referencing Form properties with Access 2003 Nightmare

smercer

Registered User.
Local time
Tomorrow, 07:52
Joined
Jun 14, 2004
Messages
442
Hi all

I have recently Upgraded from Office XP Professional to Office 2003 Enterprise edition.

Before upgrading the forms would work without a problem, now every time I want to change a subform's recordsource I get error:

"You entered an expression that has an invalid reference property Form/Report"

error number: 2455

Here is my code:

Code:
Me.sfrm_Find_Book_Book_Description.Form.RecordSource = "qry_Find_Book_Des_And_Count_Each_book_For_PopUp" 'changes record source on sfrm_Find_Book_Book_Description to "qry_Find_Book_Des_And_Count_Each_book_For_PopUp"

Can someone tell me what is wrong?

Thanks in advance!!!
 
You can set a subforms details/references?
Didn't think it was possible...
 
Ouch. I hope we never upgrade because I do the same thing... alot.
 
I use this to change the subform's data source from within the parent form...

Me.subForm1.SourceObject = "Query.MyQueryNameHere"
or
Me.subForm1.SourceObject = "Table.MyTableNameHere"
 
ghudson said:
I use this to change the subform's data source from within the parent form...

Me.subForm1.SourceObject = "Query.MyQueryNameHere"
or
Me.subForm1.SourceObject = "Table.MyTableNameHere"

Thanks ghudson, You have been very helpful. Will try it out when I get home.

Thanks again.
 
ghudson said:
I use this to change the subform's data source from within the parent form...

Me.subForm1.SourceObject = "Query.MyQueryNameHere"
or
Me.subForm1.SourceObject = "Table.MyTableNameHere"

I have not tryied it yet but isn't SourceObject for referencing forms and not tables/queries?
 
ghudson said:
I use this to change the subform's data source from within the parent form...

Me.subForm1.SourceObject = "Query.MyQueryNameHere"
or
Me.subForm1.SourceObject = "Table.MyTableNameHere"
Just tested it with RecordSource instead of SourceObject like you suggested and It comes up with the same error.

Thanks for helping
 
The SourceObject is used to change the record source of a subform for which is displayed within a parent form. I never mentioned to use the RecordSource property for that is used to change the record source of a parent form [not a subform displayed within a parent form]. The SourceObject works in Access 2003 for I tested it before I posted it above. The code example I listed above will change the data source of your subform when used. If you want to change the data source of a subform for which is displayed in a parent form then this is what you can use in VBA...

You have to use the correct "prefix" [Query. or Table.] depending if the data source is a query or table.

Code:
Me.subForm1.SourceObject = "Query.MyQueryNameHere"
Me.subForm1.SourceObject = "Table.MyTableNameHere"
 
ghudson said:
The SourceObject is used to change the record source of a subform for which is displayed within a parent form. I never mentioned to use the RecordSource property for that is used to change the record source of a parent form [not a subform displayed within a parent form]. The SourceObject works in Access 2003 for I tested it before I posted it above. The code example I listed above will change the data source of your subform when used. If you want to change the data source of a subform for which is displayed in a parent form then this is what you can use in VBA...

You have to use the correct "prefix" [Query. or Table.] depending if the data source is a query or table.

Code:
Me.subForm1.SourceObject = "Query.MyQueryNameHere"
Me.subForm1.SourceObject = "Table.MyTableNameHere"

There must be a better way, because that will cause my database to become bloatware. And all the coding would be all over the place, so I don't think that is a option.

Interestingly this works:
Code:
Forms!frm_Book_Entry_form!.sfrm_Book_Entry_Book_Description_Record_selected.Form.RecordSource = "qry_Book_Entry_Book_Description_Record_selected"

and this is for referencing a second subform in the main form.

Thanks for your input
 
Last edited:
Why do you have to make an external call to the subform if the subform is displayed within the parent form for where you are calling the code from?

Forms!frm_Book_Entry_form!.

Also, if your way works then I see no difference in the amount of code lines since one way or the other requires one line of code.
 
ghudson said:
Why do you have to make an external call to the subform if the subform is displayed within the parent form for where you are calling the code from?


Forms!frm_Book_Entry_form!.
It is a different form from the form name that is posted origanaly.
ghudson said:
Also, if your way works then I see no difference in the amount of code lines since one way or the other requires one line of code.
Just trying to get it to work.

I am starting to think that there may be something in the name or something that access 2003 doesn't like because other record source changes in my db do work.
 

Users who are viewing this thread

Back
Top Bottom