Hey, this was my question, too! But I have a further problem:
I want to open a form from code in a stand-alone module, run code that writes some values to the form, THEN have code execution wait while the user enters values on the form.
This is an audit trail program that runs before form update, detects changes and writes details to an audit trail table. For each change detected, I want to stop and make the user enter information about why the change was made. Then I want the audit trail program to resume. The values from the form will be written to the audit trail.
I tried opening the “ReasonforChange” form in dialog mode (thanks, Mile-O-Phile!), and it worked great, except then the program code stopped right away and didn’t send values to the form. (d'oh!)
Here is the gist of the code:
For Each C In tempForm.Controls
If Nz(C.OldValue) <> Nz(C.Value) Or (IsNull(C.OldValue) And Not IsNull(C.Value)) Or (IsNull(C.Value) And Not IsNull(C.OldValue)) Then
DoCmd.OpenForm "ReasonForChange", acNormal [NOT ,,,,acDialog]
Forms!ReasonForChange!Patient_ID = tempID
Forms!ReasonForChange!PageNum = tempPageNum
...etc....
Forms!ReasonForChange!Field = C.Name
Forms!ReasonForChange!OldValue = C.OldValue
Forms!ReasonForChange!NewValue = C.Value
[Here I want to go to “ReasonForChange” form, where operator enters a reason code number chosen from a combo box and may be required to enter further explanation depending on what code number is entered. (I want to go to this form so I can control and assist the choice of reason data, especially through use of the combo box with code #s and explanations.) “ReasonForChange” form has the VBA code to add a record to Audit Trail table. When operator closes “ReasonForChange,” and only then, I want to resume looping through the controls. Each time a change is detected, ReasonForChange form should open.]
End If
Next C
--------
There must be a way to do this?? Or can I accomplish what I'm trying to do without using the form? I want the reason codes and their interpretations to be taken from a table that is used as row source for the combo box.
I want to open a form from code in a stand-alone module, run code that writes some values to the form, THEN have code execution wait while the user enters values on the form.
This is an audit trail program that runs before form update, detects changes and writes details to an audit trail table. For each change detected, I want to stop and make the user enter information about why the change was made. Then I want the audit trail program to resume. The values from the form will be written to the audit trail.
I tried opening the “ReasonforChange” form in dialog mode (thanks, Mile-O-Phile!), and it worked great, except then the program code stopped right away and didn’t send values to the form. (d'oh!)
Here is the gist of the code:
For Each C In tempForm.Controls
If Nz(C.OldValue) <> Nz(C.Value) Or (IsNull(C.OldValue) And Not IsNull(C.Value)) Or (IsNull(C.Value) And Not IsNull(C.OldValue)) Then
DoCmd.OpenForm "ReasonForChange", acNormal [NOT ,,,,acDialog]
Forms!ReasonForChange!Patient_ID = tempID
Forms!ReasonForChange!PageNum = tempPageNum
...etc....
Forms!ReasonForChange!Field = C.Name
Forms!ReasonForChange!OldValue = C.OldValue
Forms!ReasonForChange!NewValue = C.Value
[Here I want to go to “ReasonForChange” form, where operator enters a reason code number chosen from a combo box and may be required to enter further explanation depending on what code number is entered. (I want to go to this form so I can control and assist the choice of reason data, especially through use of the combo box with code #s and explanations.) “ReasonForChange” form has the VBA code to add a record to Audit Trail table. When operator closes “ReasonForChange,” and only then, I want to resume looping through the controls. Each time a change is detected, ReasonForChange form should open.]
End If
Next C
--------
There must be a way to do this?? Or can I accomplish what I'm trying to do without using the form? I want the reason codes and their interpretations to be taken from a table that is used as row source for the combo box.