473,836 Members | 1,289 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
35 5022
99 New Member
Not working this way too.
Feb 20 '12 #21
759 Contributor
It seems that the function is not in the form module. It is in a separate (general) module.
If so, modify, again:
Expand|Select|Wrap|Line Numbers
  1. strQueryID=YourFormName.ID.Caption
See what is your form name in VBA because if the real name of your form is YourFormName, in VBA become something like Form_YourFormNa me.

If steel not work, post the entire code for your function here.
Feb 20 '12 #22
99 New Member
There is one more question.If I have 3 records, the count is displayed in the row of each record on the UI.As in if the count is 'n' it is displayed 'n' times because there are 'n' records displayed and count is in the same row as the reocrd.How can I rectify this?I want only one textbox to display the count of all.
Feb 20 '12 #23
99 New Member
hey! I just tried the code you gave..i.e.
strQueryID=frmP arts.ID.Caption

the name of my form is frmParts..
but there was an error: object not found
Feb 20 '12 #24
99 New Member
tried Form_frmParts.I D.Caption also..
didn't work
Feb 20 '12 #25
99 New Member
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2.     ' Display the picture for the current employee record if the image
  3.     ' exists.  If the file name no longer exists or the file name was blank
  4.     ' for the current employee, set the errormsg label caption to the
  5.     ' appropriate message.
  6.     Dim res As Boolean
  7.     Dim fName As String
  8.     strQueryID = Form_frmPARTS.ID.Caption
  9.     path = CurrentProject.path
  10.     On Error Resume Next
  11.         errormsg.Visible = False
  12.         If Not IsNull(Me!Picture) Then
  13.             res = IsRelative(Me!Picture)
  14.             fName = Me![ImagePath]
  15.             If (res = True) Then
  16.                 fName = path & "\" & fName
  17.             End If
  19.             Me![ImageFrame].Picture = fName
  20.             showImageFrame
  21.             Me.PaintPalette = Me![ImageFrame].ObjectPalette
  22.             If (Me![ImageFrame].Picture <> fName) Then
  23.                 hideImageFrame
  24.                 errormsg.Caption = "Picture not found"
  25.                 errormsg.Visible = True
  26.             End If
  27.         Else
  28.             hideImageFrame
  29.             errormsg.Caption = "Click Add/Change to add picture"
  30.             errormsg.Visible = True
  31.         End If
Feb 20 '12 #26
759 Contributor
My skill in SQL is almost null. But I think your SQL must be something like this:
Expand|Select|Wrap|Line Numbers
  1. SELECT Count(TableName.FieldName) AS CountRecords FROM TableName;
Better is that the FieldName to be the primary key. That ensure that there are not null values in this field.

Hope you understand that, in order to count all records, I use a single field in the query.
But why you not use DCount() function to perform this calculation? In Access help files this function is very well explained.
Feb 20 '12 #27
99 New Member
Yes the column of which rows are to be counted is a primary key.If I use DCount(), won't it be repeated with the other rows?I will check DCount() soon.I checked with the function we were discussing in the previous posts.
Expand|Select|Wrap|Line Numbers
  1. Public Function ValueSpareQuery() As String 
  2. ValueSpareQuery=strQueryID 
  3. End Function 
In the above function, I applied a breakpoint to debug and found that strQueryID is able to take the value from the main form but ValueSpareQuery =""
Feb 20 '12 #28
99 New Member
Hey Mihail..I used a query instead as the count is to be selected from inner join of three tables.
Feb 20 '12 #29
759 Contributor
ZIP your database and attache it to your next post.
Feb 20 '12 #30

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: 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...
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: 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: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
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.