On Jul 19, 7:49 am, Bobby <bob...@blueyonder.co.ukwrote:
Hi
I have a form which I need to call from several different parts of my
application. Depending on where it is called from, the Data source
will change. The only way I know of to open a form from VBA is to use
DoCmd.OpenForm. However, is there any way I can pass the data source
as well? I've tried using the OpenArgs parameter, which partially
works, but I have code on form.current which does a recordsetclone.
When it gets to this I get a runtime error 7951. I'm using Access
2003.
If the FilterName and WhereCondition arguments of OpenForm don't
suffice, I would continue to use OpenArgs. You could either set a
'default' recordsource for your form (perhaps a dummy one that returns
no actual records, e.g. "select * from tbl where True = False"), then
set the real recordsource using openargs when the form opens. You
could also modify your form's Current event to check to see if the
form has a recordsource property set and not attempt to use
recordsetclone unless/until it does (e.g. "If Not
IsNull(Me.RecordSource) Then...").
Bruce