Link to home
Start Free TrialLog in
Avatar of NO_CARRIER
NO_CARRIER

asked on

syntax: change formname control reference in vba code.

I have two forms.
frmNew
frmUpdate

Both contain some of the same control information to create an e-mail message. (sender name / recipient / subject / body / etc.)  Both forms can be enabled at the same time (they're on different tabs of a multi-tab)

I have ONE module to create the e-mail object itself.

Depending on if the user clicks the "Create E-Mail" button on frmNew or frmUpdate, I want the module to gather the required information for the email from that specific form.

This is what I've been doing so far:

There is a public variable (integer) called TicketType
on the frmNew onclick event:
TicketType = 1
Call CreateEmail()

on the frmUpdate onlick event:
TicketType = 2
Call CreateEmail()

Then in the CreateEmail module/function I need it to reference the correct form / controls depending on TicketType.

I was thinking of:

If TicketType = 1
    then FormName = frmMain
else
   FormName = frmUpdate
end if

Then I could have one reference for controls such as "OutlookTo = FormName.txtAccountNumber.Value" and it would reference the correct form.  unfortunately this is not the correct way to reference form controls... so I need another way to do it.
ASKER CERTIFIED SOLUTION
Avatar of TRobinJames
TRobinJames

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial