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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update recordsource for subform at runtime 1

Status
Not open for further replies.

red22j

Programmer
Aug 1, 2002
10
0
0
US
I have a problem with setting the recordsource for a subform at runtime. I want to be to alternate between two queries with the same columns at runtime. At design time I have the recordsource set to the default query. But when I change the query at runtime - I get no records returned - even when I set the recordsource to itself.

For example:
'I can see records at this point
a = Me.frmUtilPrice.Form.RecordSource
'I can see records at this point
Me.frmUtilPrice.Form.RecordSource = a
'There are no records returned.


I traced this down to a known problem in access - that microsoft curiously returns the linkchildfields and linkmasterfields to the default - which is too specific for my case. But I cannot change them back - because when I try to change linkchildfields (for example) then it gives me an error like "linkchildfields and linkmasterfiels must have the same number of fields".

Is there a workaround to this or can I set both properties in one statement to avoid this error?

Any help would be appreciated
Jon
 
use sql statement and assign to form's record source. like:
strSQL = "SELECT * FROM order"
Forms!frmMainForm.frmSubForm.Form.RecordSource = strSQL
 
I'm sorry - I guess my question was unclear...

I used SQL and it gave me the same problem. The point is that whenever I set the recordsource to ANYTHING, it automatically changes the linkchildfields and linkmasterfields to something I don't want. The example I gave above just shows that even setting the recordsource to itself creates the problem.

Jon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top