Solved

Assigning a subform to a variable using VBA

Posted on 2003-11-13
5
246 Views
Last Modified: 2012-05-04
I am trying to compare a value on the main form with the value  on a subform.   I have assigned the main form to a variable and it works fine (see below):

Dim strParent As String, strCPersonal As String
Let strParent = [Forms]![frmempinfo]![EmpNumber]

Then, I assign the subform to a variable and  I receive the error that MS Access is unable to find the form.  Make sure it is spelled correctly and that it exists.

Let strCPersonal = [Forms]![frmChildPersonal]![EmpNumber]

frmChildPersonal is what I named the subform via the main form.  The actual name of the form is frmDISPersonal.  I tried to replace that with the frmChildPersonal and I received the same error message.

~CJ~
0
Comment
Question by:prowler2
  • 2
5 Comments
 
LVL 32

Accepted Solution

by:
jadedata earned 500 total points
Comment Utility
Hey prowler2!

  This variable needs to be a form collection object.  What's more important is the name of the subform control that you need to refer to.  The name of the subform sourceobject is not used.  It is subsumed by the control.

  dim f as form

  set f = me.subformname.form
  f("controlName") = "X"

regards
Jack
0
 

Author Comment

by:prowler2
Comment Utility
Thank you.  I will try this.  I haven't been to this site in a while.  Did they stop the emailing of expert responses?
-CJ
0
 
LVL 32

Expert Comment

by:jadedata
Comment Utility
The responses are not emailed,...only notification that a question has had a comment posted to it.
0
 
LVL 39

Expert Comment

by:stevbe
Comment Utility
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: jadedata {http:#9741751}

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

stevbe
EE Cleanup Volunteer
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now