Calling function with arguments use vba

gheepok

Registered User.
Local time
Today, 17:48
Joined
Aug 29, 2010
Messages
13
Hello,

I have a Function auditTrail(myform As Form) in a module name m_software

and

Private Sub Form_BeforeUpdate(Cancel As Integer)

Dim saveAns As Integer

saveAns = MsgBox("Do you want to save changes?", vbYesNo)

If saveAns = vbYes Then
DoCmd.Save acForm, "f_asset"

DoCmd.OpenModule "m_software", auditTrail([Form])
Else
Me.Undo
End If
End Sub

i know something wrong at DoCmd.OpenModule "m_software", auditTrail([Form]) and have the type mismatch error.

can anyone solve this.
 
Thanks pbaldy

i still have no luck.

the main form works and can run the function AuditTrail2()

but the sub form have error.

i have attach the files.

Help please. Thanks
 

Attachments

I'm not sure which you're referring to, but AuditTrail2() uses ActiveForm to determine the form. When used with a subform, ActiveForm will be referring to the main form, not the subform as you might be expecting.
 
i have solve the problems.

need to name the function in m_software to
Function AuditTrailsoftware(Myform as Form)

and
DoCmd.OpenModule "m_software", AuditTrailsoftware(Form) in the
Private Sub Form_BeforeUpdate(Cancel As Integer) for f_software

Thanks pbaldy for the quick reply.

here is the new file.
 

Attachments

You do not use DoCmd.OpenModule. There is no need to open the module. You just call the procedure:

Call AuditTrailsoftware(Me)
 

Users who are viewing this thread

Back
Top Bottom