473,725 Members | 2,212 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Referencing controls on subform query

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 want to do this
as I want to use same subform on two different parent forms. Main
problem is that the subform is not part of the forms collection.

The only workaround I found was setting the query in code in the
subform_Load event.

example

subform frmSubCal has 2 comboboxes, one for year and one for week
Rowsource of cboYear is based on Calendar.Year
Rowsource of cboWeek is based on Calendar.Week , where Year=cboYear.

when I try to create this condition in query window I have to reference
through the parent form:

.... WHERE Year=[Forms]![frmParent]![frmSubCal]![cboYear]

this will, of course, fail when I drop another instance of the subform
on another parent frmParent2.

is there a way to leave out explicit name *frmParent* or have something
like Me.Parent in there? I also tried creating a public function
getYear on the sub form, referencing like this:
Where YEAR=Form_frmSu bCal.getYear()
but the subform is simply not member of the forms collection.

the only workaround I found was this in the subforms Form_Load event:

Me.cboWeek.RowS ource = "SELECT ... WHERE (((vCalender.Ye ar)=" & _
"[Forms]![" & Me.Parent.Name & "]![frmSubCal].[Form]![cboYear]))"

which appears a bit kludgy; seems to work with multiple instances of
the subform though.

In any case I want to avoid going through global variables or external
routines, the code on the subform should be self contained so that i
could drop the subform onto other forms without additional coding.

tia,
Axel

Apr 13 '06 #1
2 4074
Axel,
FWIW, Keri Hardwick did a really nice summary of referring to various
properties etc of forms and controls with examples, which is here on
AccessWeb. (good place to bookmark... it's the FIRST place I look when
I have a question.)

http://www.mvps.org/access/forms/frm0031.htm

Apr 13 '06 #2
Thanks Piet

for the interesting link. I had a look at this lots of options there
the one I tried

Me!Controlname

works in code alright but *not* in the query designer.

there I have to specify

Forms!Mainform! Subform!Control Name

which kind of defeats the purpose, as the subform could also be on
Mainform2, Mainform3 etc.

I also tried Forms("Subform name")!ControlN ame
and Forms("Subform name").Form!Con trolName
but they all give errors. I think if there was a way to get at the "Me"
keyword in query designer it would be very useful (as the query would
refer to the instance directly, not through the (unknown) parent form)

But my workaround (see original post) works, so not to worry.

regards,
Axel
pi********@hotm ail.com wrote:
Axel,
FWIW, Keri Hardwick did a really nice summary of referring to various
properties etc of forms and controls with examples, which is here on
AccessWeb. (good place to bookmark... it's the FIRST place I look when
I have a question.)

http://www.mvps.org/access/forms/frm0031.htm


Apr 13 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2590
by: Tony Williams | last post by:
I have a form on which there is a tabcontrol and on this onr of the tabpages is a tick box which opens Outlook with data from the main form and prompts the user to amend the message before being sent. The code is Private Sub Loadtxt_Click() Dim oA As Outlook.Application Dim oM As Outlook.MailItem Set oA = CreateObject("Outlook.Application") Set oM = oA.CreateItem(olMailItem)
2
4091
by: neptune | last post by:
I built a form to access a query with a 2 field primary key. It should use 2 controls to find the unique record and display the other field values on the form. In the criteria section of the query, I set the 2 primary key values equal to the 2 control values on my form. When I input a value to these 2 controls the query finds the correct record, so I know my query with the criteria works. My problem is trying to get the output values...
3
2789
by: shumaker | last post by:
This code from the subform works for getting the value of a field of the main form named "WorkSheet": MsgBox Form_WorkSheet.Recordset.Fields("Clerk").Value Each record in the mainform datasheet called "WorkSheet" has a subform. I am trying to get the controls on the subform to reference the fields in the main form, because I think that it will resolve some of my write conflict problems by not having a recordset for the subform, and...
4
1850
by: mplogue | last post by:
I have a form (frmMain) with a subform (frmSub), each with enumerated fields of the same name (txt1, txt2, etc). I'm trying to make a function that will take the values for each field in frmMain, and put them in the same-named field in the subform. Here's the function: '--------Start Code-------- Function cmdFillSub() Dim i As Integer
3
2756
by: google | last post by:
I'm developing an application for use within my company in Access 2003. I'm new to '03, the application I did for my former employer was in '97. The two applications have similar functionality (we're sales offices, and I'm doing things such as associate directories, commission calculations, order tracking, etc.). 2003 seems to have a few extra features, but I seem to continually run in to oddities that seem like they SHOULD work, but...
6
2748
by: Mat | last post by:
Dear all, What I want to do is be able to use a string to refer to a control on a subform. IE: Forms!("Form1!form2!controlA").name or
21
5099
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 form, the code errors out at the 2nd line. The error number is 13 and the description is "Type mismatch". Both controls are memo fields. I suspect that "Screen.ActiveControl.Parent" is not referencing the form as intended. Thanks for any help,...
7
2786
by: jundavid | last post by:
have a form and a subform. In the subform, I have a combo box which I would like to only show the records based on the control on the main form. Let say I have a record of employees which I would like to show on the combo box in the subform. These employees are grouped into departments. When I specify the department in the main form, I would like in my combo box in the subform to show only the employees in that department. I tried to make a...
3
3656
by: ManningFan | last post by:
Here's a fun one, mein froinds! I have a form. The form (call it MainForm) has a subform control (call it SubForm). The actual subform that SubForm displays can change based on choices made on the main form. So, SubForm can actually display SubForm1, SubForm2, SubForm3, SubForm4, etc... What I need to do is display in a messagebox the first tabbed control on the displayed SubForm.
0
8888
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8752
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9257
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9176
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9113
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6702
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3221
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2635
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2157
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.