Solved

Assigning a subform to a variable using VBA

Posted on 2003-11-13
5
277 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
ID: 9741751
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
ID: 9748132
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
ID: 9748146
The responses are not emailed,...only notification that a question has had a comment posted to it.
0
 
LVL 39

Expert Comment

by:stevbe
ID: 10025735
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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

828 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