Marshall Brooks
Member
- Local time
- Today, 01:43
- Joined
- Feb 28, 2023
- Messages
- 696
Somewhat Obfuscating, but ...
I have a form named "Form A" and another form named "Form B". Both forms have a Field named "REFERENCE". Both Forms have a Private Sub "Reference_AfterUpdate()" which validates the data in the field. That works fine for manual input, but does not work if the field is changed via VBA.
I have a "Duplicate Record" sub on each form that copies SOME of the fields to a new record in the same form. That was not doing the validation, so I added "Call Reference_AfterUpdate" and that works.
In a module, I have a Sub called "Duplicate_Form_A_To_Form_B". This has to be in a main module (not a form module), b/c I am calling it from the right-click menu of a label on Form A. Form A is already open (it is run from there), and it opens Form B, creates a new records, and copies and modifies some of the Form A fields to the fields in the new record in Form B.
However, since it is being done via VBA - it doesn't validate any of the info - might not be an issue since the VBA code should create valid info anyway, but I would like it to check.
If I add:
Call [Form B].REFERENCE_AfterUpdate
I get a compile error - "External Name Not Defined"
If I add:
Call Forms![Form B].REFERENCE_AfterUpdate
I get a syntax error.
Changing the REFERENCE_AfterUpdate from Private to Public didn't make a difference.
Finally - if it can work and changing it to public is required, will I end up with "Ambiguous Name Detected" since I also have "REFERENCE_AfterUpdate" on Form A and a "Duplicate Form B to Form A" subroutine in the Module.
Thanks in advance!!!
I have a form named "Form A" and another form named "Form B". Both forms have a Field named "REFERENCE". Both Forms have a Private Sub "Reference_AfterUpdate()" which validates the data in the field. That works fine for manual input, but does not work if the field is changed via VBA.
I have a "Duplicate Record" sub on each form that copies SOME of the fields to a new record in the same form. That was not doing the validation, so I added "Call Reference_AfterUpdate" and that works.
In a module, I have a Sub called "Duplicate_Form_A_To_Form_B". This has to be in a main module (not a form module), b/c I am calling it from the right-click menu of a label on Form A. Form A is already open (it is run from there), and it opens Form B, creates a new records, and copies and modifies some of the Form A fields to the fields in the new record in Form B.
However, since it is being done via VBA - it doesn't validate any of the info - might not be an issue since the VBA code should create valid info anyway, but I would like it to check.
If I add:
Call [Form B].REFERENCE_AfterUpdate
I get a compile error - "External Name Not Defined"
If I add:
Call Forms![Form B].REFERENCE_AfterUpdate
I get a syntax error.
Changing the REFERENCE_AfterUpdate from Private to Public didn't make a difference.
Finally - if it can work and changing it to public is required, will I end up with "Ambiguous Name Detected" since I also have "REFERENCE_AfterUpdate" on Form A and a "Duplicate Form B to Form A" subroutine in the Module.
Thanks in advance!!!