[AccessD] Closing a Form using VBA

Darryl Collins Darryl.Collins at coles.com.au
Wed May 14 00:06:39 CDT 2008


aaaah, Hi everyone.

I am sure this is dead simple, but I keep thinking in Excel.VBA rather than Access.VBA so I get stuck. urrrgh.

On Form1 I have a button that opens Form2.  Once Form2 is open I want Form1 to close itself and save any data that maybe there.

'------ Code Being Used --------------
Private Sub cmdTL_Click()
Call OpenTL_Form
DoCmd.Close  ' <-- Doing this closes the form just opened, and leaves me with the original form.
End Sub
' ------- end code -----------------

The code above resides in the Form1 code module.
Ideally I would like to make Form1 a variable so this would work from any form.

'-------Aircode Start ----
Sub AirCode()

Dim sTHIS_FORM as string

sTHIS_FORM = ActiveForm.Name
Call OpenTL_Form
[Forms]![" & sTHIS_FORM & "].Close True 'Close and save data

End Sub
' ---- End Aircode ---------

Any Advice folks?

Regards
Darryl.

This email and any attachments may contain privileged and confidential information and are intended for the named addressee only. If you have received this e-mail in error, please notify the sender and delete this e-mail immediately. Any confidentiality, privilege or copyright is not waived or lost because this e-mail has been sent to you in error. It is your responsibility to check this e-mail and any attachments for viruses.  No warranty is made that this material is free from computer virus or any other defect or error.  Any loss/damage incurred by using this material is not the sender's responsibility.  The sender's entire liability will be limited to resupplying the material.




More information about the AccessD mailing list