How to find out which Form called the procedure?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form (A) with 6 buttons on it. Made a copy of that form (AB) and
disabled 2 buttons on it. One btn opens another form(C). Form (C) on load
event, copies ID, Name and PhoneNumber from origianl form. When I use Form
(AB) to open Form (C), on load event copies ID,NAme and PhoneNumber from Form
(A).

Sub Form_Load() 'Form(C)
With Forms!frmA
Me!txtID = Forms!frmA!txtID
Me!txtName = Forms!frmA!txtName
Me!txtPhoneNumber = Forms!frmA!txtPhoneNumber
end with
end Sub

I want to make this Form_Load() event such that when it is called it will
know which Form called it and hence load its textboxes from other form,
either Form(A) or Form(AB).
 
Use the OpenArgs argument of the OpenForm Method in A and AB to pass the
form's name to C. Then in your load event in C, use the OpenArgs property to
determine who the calling form was.

Docmd.OpenForm "FormC", , , , , , "FormA"

Then in C's Load event:

If Me.OpenArgs = "FormA" Then
' Do stuff for A
Else
'Do stuff for AB
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top