I have a Form with two alternative Command Buttons, depending on data in a table which Changes as certain functions are completed.
One says "Print Draft Data" and, when this is actioned the completion date is entered on the table.
Next time the form is opened,the date under "Draft Data" is recognised, "Print Draft Data" is invisible and replaced by "Print Full Report" which is now visible.
I want, as soon as the Draft Data has been printed, the Form to close and reopen, showing the "Print Full Report" button.
Clearly it needs to show the original Record.
The Form opens originally with code from a preceding Form,
DoCmd.Openform "CReport",,ReportID = I
If, Before "End Sub" the Code states
DoCmd.Close acForm "CReport"
DoCmd.OpenForm "CReport"
the form colses and opens again, defaulting, obviously to the first Record - which we don't want.
BUT if I repeat the original command,
DoCmd.Openform "CReport",,ReportID = I
I get an error message which states:-
"The expression you entered refers to and object which is closed or not available"
In the Debug window, putting the mouse over "ReportID" I get the same message, preceded by "Report ID =<". I, (the record number) is correct because it was declared and has not changed.
So for some reason,closing a form denies access to an object in that Form when I try to use it as a parameter for reopening.
There seems to be no Command like "DoCmd.Refresh" or "DoCmd.Reset" which would put us back to square one so that we could repoen afresh.
Has anyone any ideas?
One says "Print Draft Data" and, when this is actioned the completion date is entered on the table.
Next time the form is opened,the date under "Draft Data" is recognised, "Print Draft Data" is invisible and replaced by "Print Full Report" which is now visible.
I want, as soon as the Draft Data has been printed, the Form to close and reopen, showing the "Print Full Report" button.
Clearly it needs to show the original Record.
The Form opens originally with code from a preceding Form,
DoCmd.Openform "CReport",,ReportID = I
If, Before "End Sub" the Code states
DoCmd.Close acForm "CReport"
DoCmd.OpenForm "CReport"
the form colses and opens again, defaulting, obviously to the first Record - which we don't want.
BUT if I repeat the original command,
DoCmd.Openform "CReport",,ReportID = I
I get an error message which states:-
"The expression you entered refers to and object which is closed or not available"
In the Debug window, putting the mouse over "ReportID" I get the same message, preceded by "Report ID =<". I, (the record number) is correct because it was declared and has not changed.
So for some reason,closing a form denies access to an object in that Form when I try to use it as a parameter for reopening.
There seems to be no Command like "DoCmd.Refresh" or "DoCmd.Reset" which would put us back to square one so that we could repoen afresh.
Has anyone any ideas?