473,386 Members | 1,860 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Referencing one form from another

Hello,

What I am trying to do is have one form loop through its combo boxes and check to see if the value is a key word like Query_Form or Query_Form2. What I then want to happen is in either case to call another form that does on the fly calculations and then stores them in separate queries.

On this new calculation form I want to have a way of saying something along the lines of
If 'the other form' says Query_Form .. then call this version of the query
ElseIf 'the other form' says Query_Form2 ... then call this version of the query

My Code so far is as follows..

For the first form:

Expand|Select|Wrap|Line Numbers
  1.   For i = 1 To 29
  2.         If Me.Controls("cboField" & i) = "Query_Form" Then
  3.         'Opens frmVarCalc form as a dialog box so user must take action before rest of code is run
  4.         DoCmd.OpenForm "frmVarCalc", , , , , acDialog
  5.         ElseIf Me.Controls("cboField" & i) = "Query_Form2" Then
  6.         DoCmd.OpenForm "frmVarCalc", , , , , acDialog
  7.         End If
  8.     Next i  
For the calculation form I then have:

Expand|Select|Wrap|Line Numbers
  1. If Forms!Make_Report.Controls() = "Query_Form" Then
  2.     Call fCreateQueries("VarCalc_Query")
  3.     Call fCreateUpdateQueries("Update_Projects")
  4. ElseIf Forms!Make_Report.Controls() = "Query_Form2" Then
  5.     Call fCreateQueries("VarCalc_Query_Two")
  6.     Call fCreateUpdateQueries("Update_Projects_Two")
  7. End If 
I know the mistake is most likely in the Forms!Make_Report.Controls() statement, but I don't know how to check which combo box on the other form it is.

Any help would be greatly appreciated. Thanks!
Apr 7 '08 #1
2 2109
Stewart Ross
2,545 Expert Mod 2GB
Hi. You can refer to controls on another form by providing the name of the control just as you have done within the main loop:

Forms!formname.Controls(controlname) or
Forms(formname).Controls(controlname) amongst others.

However, if you don't know which control name to refer to it would suggest that your current design is somewhat flawed. If it is not apparent to you how is it going to be for your users?

Looping through 29 controls on one form to check whether or not to use some form of query by form is required seems a bit odd really, but without knowing more about why you are doing so I can't comment further.

-Stewart
Apr 8 '08 #2
The reason I need to loop through the comboboxes is because they help set fields for a dynamic report and the user will want to change which columns fall where each time they create the report.

Thanks for your help, I've found a post that suggests setting a global variable to be either Query_form or Query_form2 so that the second form can reference it. So far it seems to be working!

Thanks again!
Apr 9 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: J. Black | last post by:
Hello everyone - I've been developing an incident tracking and reporting system for an emergency services outfit that I work with part time. It's going well, except for one fly in the ointment....
6
by: jstaggs39 | last post by:
I want to create a Dcount and an If...Then...Else statement to count the number of records in a table based on the date that is entered to run the form. The If....Else statment comes in because if...
1
by: Faktor_one | last post by:
Does referencing objects increase memory consumption? For example, if I call public function in one form from another form and give "this" as argument, is it just pointing to the form or does it...
6
by: martin | last post by:
Hi, I am a web page and a web user control. My web user control is placed in my web page using the following directive <%@ Register TagPrefix="uc1" TagName="Header"...
5
by: Amelyan | last post by:
I am struggling here trying to determine what is a good programming practice as far as referencing your URLs. When you use Response.Redirect, do you use 1) Hard-coded string --...
2
by: Stan | last post by:
I have a dataset in one form that I instanciate there. I would like to access that dataset from another form. dim ds as new myds (myds is a dataset on the first form and is generated from a...
2
by: Axel | last post by:
Hi, a question about something that seems very simple at first glance: is it possible to reference other controls of a subform in a query window without referencing through the parent form? I...
21
by: cmd | last post by:
I have code in the OnExit event of a control on a subform. The code works properly in this instance. If, however, I put the same code in the OnExit event of a control on a Tab Control of a main...
1
by: menyki | last post by:
How do i declare a variable in a form if i want to reference to the variable from another form. Below is a code on a form called updatemortalityForm, some variable on this form, i want to make use of...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.