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

Subform Record Count Using Textbox

173 100+
Hi,

Can some please provide me with the code for counting records in a subform and displaying it in a textbox?

Does this code go into the control source of the textbox?

My subform is called 'Asset subform' within the form 'Form1'.. the textbox will be in the same form.


Also im showing records in a subform by selecting a user from a combobox...

How can i input a users name in a textbox once i have selected him from the combobox?


All help will be appreciated
Aug 29 '07 #1
11 9443
ADezii
8,834 Expert 8TB
Hi,

Can some please provide me with the code for counting records in a subform and displaying it in a textbox?

Does this code go into the control source of the textbox?

My subform is called 'Asset subform' within the form 'Form1'.. the textbox will be in the same form.


Also im showing records in a subform by selecting a user from a combobox...

How can i input a users name in a textbox once i have selected him from the combobox?


All help will be appreciated
In the Control Source of the Text Box on Form1, place the following code:
Expand|Select|Wrap|Line Numbers
  1. =DCount("*","<Record Source for Sub-Form>","[<Linking Field>]=" & Forms!Form1![<Primary Key>])
Aug 29 '07 #2
Beany
173 100+
In the Control Source of the Text Box on Form1, place the following code:
Expand|Select|Wrap|Line Numbers
  1. =DCount("*","<Record Source for Sub-Form>","[<Linking Field>]=" & Forms!Form1![<Primary Key>])

for some reason im getting an error : Error?

ive inserted the following code:

=DCount("*","<Asset subform>","[<Text16>]=" & Forms!Form1![<ID>])

Am i doing something obviously wrong?

My subform is called: Asset subform
My Form is called: Form1
TextBox is called: Text16

and the primary key for my main table is 'ID'...

im confused???
Aug 29 '07 #3
missinglinq
3,532 Expert 2GB
First off, drop the < and > ! When used in example code, whether here or in text books, <Things Like This> takes the place of an object name, so if your Primary Key is named ID,

[<Primary Key>]

would become

[ID]

when you actually write your code.

Linq ;0)>
Aug 29 '07 #4
Beany
173 100+
Hi,

thanks for reply,

ive tried that, got rid of the <>

but im still getting an error??
Aug 29 '07 #5
ADezii
8,834 Expert 8TB
Hi,

thanks for reply,

ive tried that, got rid of the <>

but im still getting an error??
Replace Asset subform with the Name of the Record Source for the Sub-Form via Select Asset subform ==> Properties ==> Data Tab ==> Record Source.
Aug 29 '07 #6
Beany
173 100+
Thank you for the replies..

the record source for my subform is:

Expand|Select|Wrap|Line Numbers
  1. SELECT Asset.ID, Asset.Asset, Asset.[Product Type], Asset.Manufacturer, Asset.Description, Asset.[Model No], Asset.[Serial No], Asset.[Windows Key], Asset.User, Asset.Department, Asset.Location, Asset.[Comms Date], Asset.Returned, Asset.[Return Reason] FROM Asset WHERE (((Asset.User) Like Forms!AssetMain!Combo2)); 
so ive got the following:

Expand|Select|Wrap|Line Numbers
  1. =DCount("*","SELECT Asset.ID, Asset.Asset, Asset.[Product Type], Asset.Manufacturer, Asset.Description, Asset.[Model No], Asset.[Serial No], Asset.[Windows Key], Asset.User, Asset.Department, Asset.Location, Asset.[Comms Date], Asset.Returned, Asset.[Return Reason] FROM Asset WHERE (((Asset.User) Like Forms!AssetMain!Combo2))","[Text16]=" & [Forms]![Form1]![ID])
But im still seeing an error?? y?
thanks
Aug 30 '07 #7
ADezii
8,834 Expert 8TB
Thank you for the replies..

the record source for my subform is:

Expand|Select|Wrap|Line Numbers
  1. SELECT Asset.ID, Asset.Asset, Asset.[Product Type], Asset.Manufacturer, Asset.Description, Asset.[Model No], Asset.[Serial No], Asset.[Windows Key], Asset.User, Asset.Department, Asset.Location, Asset.[Comms Date], Asset.Returned, Asset.[Return Reason] FROM Asset WHERE (((Asset.User) Like Forms!AssetMain!Combo2)); 
so ive got the following:

Expand|Select|Wrap|Line Numbers
  1. =DCount("*","SELECT Asset.ID, Asset.Asset, Asset.[Product Type], Asset.Manufacturer, Asset.Description, Asset.[Model No], Asset.[Serial No], Asset.[Windows Key], Asset.User, Asset.Department, Asset.Location, Asset.[Comms Date], Asset.Returned, Asset.[Return Reason] FROM Asset WHERE (((Asset.User) Like Forms!AssetMain!Combo2))","[Text16]=" & [Forms]![Form1]![ID])
But im still seeing an error?? y?
thanks
You must use a Table name or Query for the 2nd Argument for the DCount() Function as in:
Expand|Select|Wrap|Line Numbers
  1. DCount("*", "<Table Name>")
  2. DCount("*", "<Query Name>")
Aug 30 '07 #8
Beany
173 100+
You must use a Table name or Query for the 2nd Argument for the DCount() Function as in:
Expand|Select|Wrap|Line Numbers
  1. DCount("*", "<Table Name>")
  2. DCount("*", "<Query Name>")

honestly im confused now, why two Dcounts?

thanks
Aug 30 '07 #9
missinglinq
3,532 Expert 2GB
Use one or the other !
Aug 30 '07 #10
Beany
173 100+
excellent,

thank you for your patience...

it counts the records now.... it counts the users in the table 'Asset'.

Im selecting a user from a combobox, and then displaying the records for this user in the subform. how can i get it to count records in the subform?
Aug 30 '07 #11
Beany
173 100+
anyone?

any help will be appreciated..

thanks
Aug 30 '07 #12

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

Similar topics

15
by: Rey | last post by:
Howdy all. Appreciate your help with several problems I'm having: I'm trying to determine if the Visit subform (subformVisits) has a new record or been changed, i.e. dirty. The form that...
8
by: PeteCresswell | last post by:
I'm looking for some code that makes a list presented in a subform autoscroll in response to the user typing - like a combo box dropdown or a regular ListBox does. I.e. The user is looking at...
0
by: Carl | last post by:
I have a main form with navigation buttons on it and a label showing for example Record 1 of 15 using recordsetclone on it and eveything works fine. When I move through the records the record...
2
by: CSDunn | last post by:
Hello, In an Access 2003 ADP Subform, I am trying to set the BackGround color of three textbox fields (LSScore, RScore, WScore) in the current record of the subform to zero (black) if the value of...
2
by: Simon P | last post by:
Hello group, I'm in desperate need of help. Here goes : I have the following tables : CONTACTS (ContactID, FirstName, LastName, Company, etc.), SHOWS (ShowID, ShowDescription) and SHOWDETAILS...
3
by: Joshua Ammann | last post by:
Hi, (Using Access 2000) I have two tables, similar to Customers and Orders. (Not an exact parallel, but works for this example.) On a form showing customer data, there is a tab control. One...
5
by: Lyn | last post by:
Hi, I have a form which contains a number of subforms in different pages of a tab control. In the detail section of each subform, I list records related to the main form record, but from...
3
by: matthewemiclea | last post by:
So I think this may be a stretch, but I have a subform that is displayed on a main form. The subform is based on a query that brings records from a table(It does not bring all fields, but the main...
13
by: bitsnbytes64 | last post by:
Hi, I have a form which contains a subform. Both are were creetd using the form wizard and are bound by the column IXO_NR (on two different tables), which is the control source for a textbox on...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work

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.