troubleshooting Question

syntax: change formname control reference in vba code.

Avatar of NO_CARRIER
NO_CARRIER asked on
Microsoft AccessVB Script
1 Comment1 Solution557 ViewsLast Modified:
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.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 1 Comment.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros