Count records from different table

Not sure if this is even do-able or not.

I have a form (lets call it FORM A) that has details information about each 
Case.  Each case can have multiple Collection records.

I want text box on FORM A that just tells me the number of Collection 
records with the same Case number.

I tried DCount in a new unbound text box, but i just get '#Error'.

Any suggestions?

0
Utf
3/30/2007 5:40:04 PM
access.forms 6864 articles. 2 followers. Follow

2 Replies
1844 Views

Similar Articles

[PageSpeed] 16

You can use an unbound textbox, and in the form's On Current event open a 
recordset of the table, then populate the textbox with the recordcount from 
that recordset.

For example, if your other table was called TBL and you want to show the 
number of records in TBL in a textbox called txtBox on a form based on the 
table TBL123:

    Dim cnx As ADODB.Connection
    Dim rs As New ADODB.Recordset
    Set cnx = CurrentProject.Connection

    rs.Open "TBL", cnx, adOpenKeyset, adLockOptimistic, adCmdText
    Me.txtBox = rs.RecordCount

If you wanted to count the number of records with a where condition, you can 
either use a stored query or a SQL statement in place of the table name 
("TBL")

-- 
hth,
SusanV

"Nathan" <Nathan@discussions.microsoft.com> wrote in message 
news:839ED1B0-8323-4FA5-93FE-09B267A40FB5@microsoft.com...
> Not sure if this is even do-able or not.
>
> I have a form (lets call it FORM A) that has details information about 
> each
> Case.  Each case can have multiple Collection records.
>
> I want text box on FORM A that just tells me the number of Collection
> records with the same Case number.
>
> I tried DCount in a new unbound text box, but i just get '#Error'.
>
> Any suggestions?
> 


0
SusanV
3/30/2007 5:49:20 PM
On Fri, 30 Mar 2007 10:40:04 -0700, Nathan wrote:

> Not sure if this is even do-able or not.
> 
> I have a form (lets call it FORM A) that has details information about each 
> Case.  Each case can have multiple Collection records.
> 
> I want text box on FORM A that just tells me the number of Collection a
> records with the same Case number.
> 
> I tried DCount in a new unbound text box, but i just get '#Error'.
> 
> Any suggestions?

DCount is just fine, but you didn't tell us what your DCount syntax
was so it's hard to guess what your difficulty is.
Try something like this:

=DCount("*","TableName","[CaseNumber] = " & Me.[CaseNumberOnForm])

The above assumes that [CaseNumber] is a Number datatype.

If, in fact, [CaseNumber] is a Text datatype, then use:

=DCount("*","TableName","[CaseNumber] = '" & Me.[CaseNumberOnForm] &
"'")

Change the table and field names as appropriate.

Make sure the control name is not the same as the name of any field
used in it's control source expression.
-- 
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
0
fredg
3/30/2007 6:53:27 PM
Reply:

Similar Artilces:

Pivot table and counting.
I have a pivot table that gives me the number of rides done by a van. I can have the pivot table return the number of rides, but what I need is the number vans that participated for a certain day. Example, it is possible to have 27 trips done by 18 vans, how can I count the number of vans and not addup the van number? Any help appreciated. Thank you, Joe Hi Joe We need a bit more information on how your source data table is set up. What information do you have in each column? -- Regards Roger Govier sacredarms <sacredarms@discussions.microsoft.com> wrote: > I have a pi...

Store Operations POS Item Table Field Suggestion
We would like to suggest adding a new "numeric" type field in the "Item" table of Store Operations. All of the customers that we have dealt with have only used numeric values in the "ItemLookupCode" field, however this field is an alphanumeric string, and does not offer true numeric sorting in applicable browsers. Not to alienate those clients that use alphanumeric characters in the ItemLookupCode field, we suggest adding several true numeric fields for custom data, then the user could sort on their numeric data. In addition to our encounters with numeri...

Invalid Pivot Table Message
I created a cube (under Analysis Server Windows 2000) with some date fields and processed it. Everthing went fine. I then created an Excel (XP) spread sheet and did 'Import External Data' / 'New database query' / 'OLAY Cubes' / to my cube. I saved the spreadsheet and sent it to my co-worker. When he opened the spreadsheet on his PC it opened fine; but when he double clicked on a year column to expand, he got a message 'Invalid Pivot table'. What am I doing wrong? Thanks, S.Kumar P.S. I posted a similar message in the sqlserver.olap forum but there was no ...

Cycle Counting
Hello, I am looking for ideas on how to cycle count serial number tracked items without increasing workload. Our serialized items are barcoded but the problem is the are situated on the pallet incorrectly and the pallet is placed on a third level of a racking system. If we could just cycle count based on item count and not include the serial number it would make it easy. Is this possible in Great Plains. We are running Great Plains 8.0. Any suggestions are greatly aprreciated. Thank You, Brian Morris Database Administrator ...

Lookup table with click-and-select?
Can someone point me in the right direction? I have several thermos bottles of various sizes that I use for tea. I have several varieties of tea that require different brewing parameters. I'd like to create a worksheet that will generate "brew slips" -- little slips of paper that show how much tea to use for each thermos. The left side of the sheet will be the brew sheet. It will have columns for ounces, cups, milliliters, grams of tea, etc. Something like this: Thermos Cups Oz mL g/pot A 2.0 16 473 ?? B 3.0 24 710 ?? C...

Count
Hi, I would like to know how which formula I should use to count some codes & to ignore the duplicated codes, for example in column A: Code 1234 4321 4321 1234 1234 3214 Now, I want Excel to count & the result is 3 which are: 1234-4321-3214 Yes I can use PivotTable, but I would like to use a formula because I have to deal with this every day. I appreciate your support. -- MFS22 COUNTIF will do it. =COUNTIF(Rng,Rng), where the criterion is the same as the range: e.g =COUNTIF(A3:A8,A3:A8) HTH Peter "MFS" wrote: > Hi, > I wo...

Mathematical Calculations in a form linked back to a table
Hello I palnning on implementing calculation between two fields, and the result within another field. Suppose I have three fields called A B and C respectively. In the form I plan on Inputing a value for[A] and Inputing a value for [B]. Now, Field [C] will calculate [A]-[B]. When filed [C] is calculated, it is not in the table, like A and B are. I would like to know how to solve this problem. It is rarely necessary to store a calculated value in a table in Access. Much more commonly, a form (as you are using) or a query is used to do the calculation "on the fly", as it were. ...

Looking for Macro to load data from Access table
I need to code a button to delete data in a spreadsheet then reload the data from an Access table. I'm a new excel user so I down know where to start. Thanks Maybe this will help http://www.rondebruin.nl/accessexcel.htm -- Regards Ron de Bruin http://www.rondebruin.nl "Randy K" <wawork@hotmail.com> wrote in message news:43ff7bea.3595531@msnews.microsoft.com... >I need to code a button to delete data in a spreadsheet then reload > the data from an Access table. I'm a new excel user so I down know > where to start. > > Thanks ...

How do I count the # of times a value reoccurs and plot it over ti
I wish to plot a number of errors made by each users and compare it over time. I have a column of user ID's and a column of dates. I want the chart to count the number of times each user ID appears and plot against it's corresponding date. However, each time I try to do this, the chart appears wrong. Any ideas? In article <9595B2A1-8282-4AB3-8511-A6776E108164@microsoft.com>, Stephen@discussions.microsoft.com says... > I wish to plot a number of errors made by each users and compare it over > time. I have a column of user ID's and a column of dates. I want t...

Resources
I understand there is a feature in Great Plains where I can pull up any screen in eEnterprise and see what column and table that text box is linked to? Is this true? What are the steps to get this information? ...

Line count
I am working with a program called Dictaphone. We use Word 2007 in this program. The line count on Dictaphone and the line count in Word 2007 are different even though the Dictaphone text is retrieved from Word 2007. Why would they be different? What is the difference between virutal line count and physical line count? ...

count number of characters in rich edit control
How can i count number of characters in rich edit control 2 If u mean controls of type Rich TextBox control, try RichControl1 RC1; CString Mes=RC.GetText(); int n=Mes.GetLength(); "Rahul" <Rahul@discussions.microsoft.com> wrote in message news:7743023C-EA83-4ACA-AB67-F1AE7279F1EB@microsoft.com... > How can i count number of characters in rich edit control 2 EM_GETTEXTLENGTHEX, WM_GETTEXTLENGTH, WM_GETTEXT, EM_STREAM* "Rahul" <Rahul@discussions.microsoft.com> wrote in message news:7743023C-EA83-4ACA-AB67-F1AE7279F1EB@microsoft.com... > How can i co...

Counting sales
I have two different datasets. Each with a common identifier. I need a formula that will reference the identifiers in both datasets and count the number of sales a particular agent made. Example. look up this identifier in the other dataset and then give me the value that is 2 columns over from the identifier in the second dataset. See if this helps: http://contextures.com/xlFunctions02.html -- Biff Microsoft Excel MVP "Dave" <Dave@discussions.microsoft.com> wrote in message news:E7245B37-033F-400E-9CEE-9822BE7CB0F5@microsoft.com... >I have two...

Counting Cells with Conditional Formatting
Is there a way to look at a row of data that is either highlighted yellow or red and to count only the data that is highlighted yellow and give me that number? None of my data is numerical....just one letter data, i.e.: "S" or "U" I just want to count how many of the cells are highlighted yellow in a specific row, if that makes more sense. Here's a UDF (Put in a Standard module) and use it in cell A1, like =CountByColor(A8:H8,6) << where 6 (at present) = Yellow = change to =CountByColor(A8:H8,3) to get the reds HTH Function CountByColor(InRa...

COUNT ? need formula
Hi, I want to track the results of my teams sales performance. I record if it is a sale, no sale, cancelled etc in column M. I thought I'd be able to use the COUNT function/formula to be able to search for all the SALES in column M and place the result in a cell ( column O )but I can't work it out. Any ideas? Damian Hi! Try this: =COUNTIF(M1:M100,"sale") Biff "Diamond Jones" <kwanzaNOSPAM@optusnet.com.au> wrote in message news:43a0e897$0$17704$afc38c87@news.optusnet.com.au... > Hi, > > I want to track the results of my teams sales perf...

Count Function
I am creating a report for the number of pupils being collected at a certain collection time e.g. 14:00hr and 15:00hrs using the formula =Count([Child Last Name]) in the collection time footer However when i try to count the overall number of pupils in the footer using the same formula, 'Error' appears on screen? Thanks There are potentially a dozen footer sections in a report. Which one is giving you a problem? What is the name of the control? What is the exact formula? -- Duane Hookom Microsoft Access MVP "ELo" wrote: > I am creating a r...

Problem using FOXPRO Free Tables from Access 2000
I'm using Access 2000 linking FoxPro Tables via ODBC When I link tables with numeric fields Access gives me an error: "The Decimal field's precision is too small to accept the numeric you attempted to add." I find this problem in "Knowledge Base" I update my Windows XP to Jet 4.0 SP8 with Mdac 2.8 RMT and the last version of FoxPro ODBC Driver and but the problem is the same. Any help appreciated. ---------------------------------------------------------------------------- ---- ACC2000: Scaling Errors When You Query Linked Tables PSS ID Number: 270...

Counting a count
How do I count a count?? This is what im trying to do: I have a database with a table named tblMain and has incorporated everything within that table but contains info from about 8 other tables. I have not doesigned this database and it appears to have a very poor structure...anyway There are three fields involved in this process...'Request' (either 'dispensation', 'waiver' or 'dispensation and waiver'), 'Department' (which consists of 7 other drop down menu options) and 'RequestStatus' which contains the status of each request by another...

Table or Query?
I've been racking by brain and various books to find some answers, but to no avail. I need assistance with a simple task. I have a combo box that looks up items from a table. Once an item is selected, I do not want it to appear again. Should I be using a query for my control source? Please help!! Any assistance would be greatly appreciated. Thank you!!! When you say "Once an item is selected, I do not want it to appear again.", what is the scope? Do you mean never ever again or do you mean while the form is open? It makes a difference in how you will approach this. ...

2002 Pivot Table Calculating Field
Can you place a calculated field in a Column next to an Excel List field? Example: Total Quater1 % Quarter2 % Quarter3 % Quarter4 % Sales Sales Sales Sales Sales 240 10 4 75 31 105 44 50 21 The % field is not in the Excel List. List example: Area Quarter Sales 1 2 50 2 3 75 3 2 25 4 1 10 5 4 35 6 ...

Recording Administrative Fee on 401(k) in Money 2007
What is the appropriate way to record an administrative fee charged to shares on a 401(k) in Money 2007 - an "Other Expense" doesn't allow for a change in shares and faking out the software by entering a negative "Reinvested Capital Gaines" doesn't work either. Thanks, Phil D. I do a Sell to the Cash Account followed by an Expense (Miscellaneous:Service Charges & Fees or similar) in the Cash Account. I'm assuming you are not wanting to do the Sell. Why not? "Phil" <PhilipDeLaneyWV@gmail.com> wrote in message news:1168372938.333254.7351...

Count Problem
Hi I have 20 cells in a single column in a sheet called "Audits" All the cells have a formula in them. The formula is a simple one that reads whatever I put into a cell on a different worksheet called "Names" ie: =Names!A1 = Names!A2 etc etc I would like to have a formula that counts up all the results I get in the sheet called "Audits" At the moment if I enter (let say) 15 names in the "Names" sheet the result is that I see the same 15 names in the "Audits" sheet, however the COUNTA formula returns a total of 20. SO obviously...

unique or distinct count from xml
How to get a unique count from a xml <Orders> <Order ID="1111" Amount="200"></Order> <Order ID= "2222" Amount="10"></Order> <Order ID="3333" Amount="5"></Order> <Order ID="1111" Amount="20"></Order> </Orders> The result should be 3 unique count and the 4 Order Id counts. How can i get using XPathNodeIterator using Compile,Execute with a XPathNavigator thanks you bhu The XPath expression for that is count(Orders/Order[not(@ID=preceding-sibling::Or...

How can I search for and display actual record numbers in Access?
I have a form that has several fields to save data in for achieve purposes. I also have a search form that pulls that data and displays it, each in an individual line. It would be ideal to be able to click on a search result and then on the main form have that record be displayed. I do not know how to do that, so I was hoping to just be able to display the record number in the search results so that you can just type it in the main form and go right to that record number. I am unable to do that either, I tried several combinations of displaying something like me.currentrecord for ...

duplicate numbers being given different rankings
Have list of percentages which have been sourced from another sheet within an excel document - when i rank these some duplicates are given the same ranking and some are given different rankings eg. 2 results of 6.16% were both ranked 13 while 2 results of 6.11% were ranked 10 & 11 Increase the number of decimals to see whether the cells contents are exactly same or is rounded off and displayed as 6.11 -- Jacob "Mantis" wrote: > Have list of percentages which have been sourced from another sheet within an > excel document - when i rank these some dup...