473,387 Members | 1,624 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,387 software developers and data experts.

Referencing a control on a subform

60
Hi Everyone,

I thought I had this right but I can`t understand why I get this error. When Access encounters the line of code below it says Microsoft Access cannot find the field traffic_subform referenced in your expression.

The traffic_subform is a subform of the count_stations_form and I`m trying to reference a control on the traffic_subform.

ElseIf rs.RecordCount = 0 And Forms![Count_Stations_Form]![Traffic_Subform].Form![Number_of_Records] = 1 Then

Any ideas

Thanks as always.

Ramprat
Nov 24 '08 #1
4 976
puppydogbuddy
1,923 Expert 1GB
Your reference depends on whether the code that includes the reference is executed from the main form or from the subform. The reference you provided above appears to be the correct reference syntax used in code executed from the main form. If, however, the reference is being made in code being executed from the subform, then your reference would look as shown below. Could that be your problem?

ElseIf rs.RecordCount = 0 And Me![Number_of_Records] = 1 Then
__________________________________________________ _____

If the above is not the problem, it would appear that your reference should be to the recordset object (rs!xxxxxxxxxxxx) and not the form object directly..
Nov 24 '08 #2
LBryant
18
If you are getting the recordcount of your subform from the main form or the subform itself, you can use the RecordCount property. In this example, MySubform is the "name" of the Subform control on your main form.

From main form:

Expand|Select|Wrap|Line Numbers
  1. NumberOfRecords = MySubform.Form.Recordset.Recordcount
In the subform's code, you can use:

Expand|Select|Wrap|Line Numbers
  1. NumberOfRecords = Me.Recordset.RecordCount
Nov 24 '08 #3
ChipR
1,287 Expert 1GB
I always get confused and go back to this chart:

Forms: Refer to Form and Subform properties and controls
Nov 24 '08 #4
ramprat
60
Thanks guys. The combination of answers helped me sort it out.
Nov 25 '08 #5

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

Similar topics

5
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...
2
by: William Wisnieski | last post by:
Hello Everyone, Access 2000 I have a main form with a continuous subform. On the main form I have a text box that references a field on the subform. What I'd like it to do is show the value...
3
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...
4
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,...
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...
6
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
9
by: Alan | last post by:
Hmmm, I'm not too good with the syntax of referencing a subreport. I have frmInvoice which has the invoice details (e.g. ProductCode, ProductCost etc) in the subform frmInvoiceDetails. I'm trying...
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...
7
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...
3
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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.