Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing Subform Recordset from Mainform's code 1

Status
Not open for further replies.

Cybernetic2002

Programmer
Nov 20, 2001
7
CA
In my project there is a subform that needs to have it's RecordSource updated dynamically through code.

When the user changes the record on the main form, I want the subform to be updated to match the mainform. In order to do this I have to change the subform's RecordSource(Could also use the Filter property) each time the Main form changes to a different record.

In my Main Form_OnCurrent it changes the ID# on the subform to match that of the Main form. But when I try to change the RecordSource of the mainform Access comes back with error# 438: Object doesn't support this property or method.

Here is the code I am using to assign the subform's recordsource. As far as I can tell there is no way to set the recordsource in a subform unless it is actually done in that subform's module.

Forms!qBookings.frmqCars.RecordSource = carRecordSource

If anyone could help me with this or has any other ideas that could make this work I would appreciate it greatly. I am getting desperate as this project is starting to become LARGELY overdue. HELP ME PLEASE!!!

Cyb.
 
What I understand that your code changes the recordsource of the subform. if carRecordSource is a string (SQL string), your code should be:

frmqCars.form.RecordSource = carRecordSource
frmqCars.form.requery

assuming that the main form is qBookings.


Seaport
 
Seaport:

Thank you SOOOOOOOOOO much for your help. That code does exactly what I wanted. Again, THANK YOU.

Cyb.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top