troubleshooting Question

How to use ElseIf and With together

Avatar of wlreimer
wlreimer asked on
Microsoft OfficeMicrosoft Access
6 Comments2 Solutions280 ViewsLast Modified:
I inherited an application that has multiple versions of a single form that all access the same subform.

The subform then refers back to the form that opened it to obtain some information.  However, it's missing a reference to one of the parent forms and I'm not sure how to make it work correctly.

This is the code it has right now:
        If FormIsLoaded("Catalog Floorcovering") Then
            With Access.Forms("Catalog Floorcovering")
                m_strVendor = .Controls("Vendor")
                m_strProductNum = .Controls("VendorStyle")
                m_strProductOpt = .Controls("TextProductOption")
            End With
        Else
            With Access.Forms("Catalog")
            m_strVendor = .Controls("Vendor")
                m_strProductNum = .Controls("Product")
                m_strProductOpt = .Controls("ProductOption")
            End With
        End If

What it's missing is the option to get the info it needs when it's opened from a form named "Catalog CPA" which is just another (slightly different) version of "Catalog" or "Catalog Floorcovering".  

I thought I'd be able to use Else If, but that errors.

Any help with how to add:
            With Access.Forms("Catalog CPA")
            m_strVendor = .Controls("Vendor")
                m_strProductNum = .Controls("Product")
                m_strProductOpt = .Controls("ProductOption")
            End With

Would be greatly appreciated!
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 2 Answers and 6 Comments.
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 2 Answers and 6 Comments.
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