473,836 Members | 1,501 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

passing input parameter to the subform from a form

99 New Member
I need to select count of a column and display it on a subform.To count the column, I need to pass a parameter from a form. How can I capture the parameter form and display it on the subform?All this is in MS ACCESS 2007.

the query is:
Expand|Select|Wrap|Line Numbers
  1. select count(tblequipmentbase.id) from 
  2. (tblequipmentbase inner join tblequipmentparts on 
  3. tblequipmentbase.id=tblequipmentparts.idconnect) inner join 
  4. tblparts on tblequipmentparts.idpart=tblparts.id
  5.  where tblparts.id=Forms!frmparts!ID
"frmparts" is the form
the query is written for a textbox in the subform "frmsparepartsl ist"
The parameter comes from a label.

Is the above query incorrect?Pleas e suggest some idea anyone..
This query runs fine in the sql editor when i give direct value of the parameter.
Feb 15 '12 #1
35 5025
32,584 Recognized Expert Moderator MVP
Please read [code] Tags Must be Used.

The query seems fine, but where are you using it? You can't use it as a Control Source.
Feb 15 '12 #2
99 New Member
I am using it in the control source this way control source: =(query)I can't put it in the record source as the subform already has a record source editing which leads to problems as the it does not have reference to all the tables used in the query for the text box.
Feb 16 '12 #3
99 New Member
Now I have created a query using the query wizard and I have used
=DLookUp([qrySpareparts]![InstalledQuanti ty],[Forms]![frmPARTS]![ID]) as the control source
The error in the textbox is #Name now..
The query is the same as before.Installe dQuantity is the result of the query.
Feb 16 '12 #4
759 Contributor
A possible approach:
You must provide the value for the public variable (see attachment).
Attached Files
File Type: zip Test.zip (21.5 KB, 159 views)
Feb 16 '12 #5
32,584 Recognized Expert Moderator MVP
I suspect you're on the right lines with DLookup(), but I suggest you look up how to use it properly in Context-Sensitive Help. There is little point to me simply copy/pasting what is already there, but if you struggle then let us know where and we'll do what we can to help :-)
Feb 16 '12 #6
99 New Member
:( trying options after options.I created a public variable 'strQueryID' which is assigned the value of the 'ID' of the main form in Current() function just like Mihail suggested.Then I have an invisible textbox 'txtQueryID' on the subform whose control source is
Expand|Select|Wrap|Line Numbers
  1. =ValueSpareQuery()
Expand|Select|Wrap|Line Numbers
  1. Public Function ValueSpareQuery() As String
  2. ValueSpareQuery=strQueryID
  3. End Function
Now for the textbox that displays the count from the query, the Dlookup function that's not working
Expand|Select|Wrap|Line Numbers
  1. =DLookUp([qrySpareParts]![InstalledQuantity],"[tblParts.ID]="_&[Forms]![frmSparePartsinBase]![txtQueryID])
'frmSparePartsi nBase' is the subform
Feb 17 '12 #7
99 New Member
I have removed the where clause from the query so that all the records are displayed alongwith the column the records are based on.
Expand|Select|Wrap|Line Numbers
  1. select tblparts.id,count(tblequipmentbase.id) from  
  2. (tblequipmentbase inner join tblequipmentparts on  
  3. tblequipmentbase.id=tblequipmentparts.idconnect) inner join  
  4. tblparts on tblequipmentparts.idpart=tblparts.id group by tblparts.id 
Feb 17 '12 #8
759 Contributor
Of course that DCount (or DLookup) do not work as you try.
Store the result of Dcount() (or DLookup()) into a public variable, like this:
Expand|Select|Wrap|Line Numbers
  1. YourPublicVariable = DCount(...) 'Or
  2. YourPublicVariable = DLookup(...)
then use that variable as I show you in order to have the value in your text box.
Feb 17 '12 #9
99 New Member
Isn't there a simpler, easier way of capturing the value of a label from the form and passing it to the control source of a textbox on the subform?Things are becoming complicated for me..
Feb 17 '12 #10

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

Similar topics

by: Thomas Philips | last post by:
To experiment with filtering, I define a function f(x,k) as follows >>> def f(x,k=2): return x%k==0 I can check that it works by typing >>> f(10,3) False Now, I try to filter a range using >>> filter(f(k=3),range(20))
by: carrionk | last post by:
Hi, I have created a Subform which SourceObject is a parameter query. This is the Query: Qry Name:80IsscomProduct SELECT * FROM Isscomp28 WHERE Like ;
by: josephpage | last post by:
I have a Visitor class that is defined in a class library. The class has lots of parameters that are pulled from the QueryString, the ReferrerUrl, Cookies, the Session object, etc... I would like to make a constructor for the Visitor class that accepts an HttpContext instance from within Session_Start in Global.asax.cs as an input parameter. The problem is that I can't figure out how to reference HttpContext from within my Visitor...
by: David W. Fenton | last post by:
I think at various times we've all encountered this problem: A subform is on a main form. From the code of the main form we refer to some property of/control on the child form thus: Me!subForm.Form!txtTextBox and for some reason, in certain contexts, we get the error: Error 2455: You entered an expression that has an invalid reference
by: kulungele | last post by:
Hi there, First of all, greetings from a newbie with Access. I have a View (let's call it view1) that asks for a parameter called "Factory?". I have a Report with 2 graphics and a data table that come from 3 different views, but all the views depend from the original view1. When I try to show the Report, it asks for the parameter Factory, but it does it 3 times (2 graphics + 1 data table). The user is getting angry because I don't know...
by: vijaykumardahiya | last post by:
Hello Sir, I have a simple Issue but It is not resolve by me i.e input parameter are not store in Ms-Access. I store the input parameter through Standard Action <jsp:useBean>. jsp:useBean call a property IssueData. this property exist in SimpleBean which create a connection from DB and insert the data. At run time servlet and server also show that loggging are saved in DB. But when I open the table in Access. Its empty. Ms-Access have...
by: htenay | last post by:
I need to be able to define an array in Java and pass it on to SQL stored procedure. I am new to store proc and found a lot of helpful tutorials on Google but found none that passes parameter of type list, process and return result. My question is: I like to be able to pass input parameter of type list into stored procedure and pars the list, process it and return result set. It is an SQL stored procedure (in DB2) that is called with in...
by: gjain12 | last post by:
Hi All, I want to create an Input Parameter in my procedure which can take a long string of 3000 or more characters. The strored procedure then use this input parameter as clob type to a function which would do further processing. But I am not able to find how to create input parameter for such a long string haivng 3000 or more characters. Any pointers would be very helpful. Thanks, Abhishek Chowdhury
by: doma23 | last post by:
Hello everyone, I didn't use Access some time and now I'm struggling for couple of hours already with something that I used to know... I need to pass the parameter (date) from a comboxes on a form to a query. This is what I have in the query for particular date field: IIf (!! Is Null Or !! Is Null;
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,...
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...
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,...
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...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
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
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
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.