473,416 Members | 1,628 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,416 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 9459
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
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
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...
0
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...
0
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...

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.