Avatar of NO_CARRIER
NO_CARRIER asked on

syntax: change formname control reference in vba code.

I have two forms.

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
   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.
Microsoft AccessVB Script

Avatar of undefined
Last Comment

8/22/2022 - Mon

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy