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

Problems with DCount

AccessIdiot
493 256MB
I have a form (frm_Specimen_Entrainment) that contains a subform (sbfrm_FishSpecimen_Entrainment). The subform has to be in datasheet view.

On the form I have an unbound textbox where the user can enter the number of specimens. The subform only appears if the specimen is a fish. The subform allows the users to record data about fish only.

The user would like me to add in functionality whereby the computer counts the number of records put into the subform and displays that in the textbox on the form. This would be a nice feature to avoid error actually since if they entered 12 records into the subform but counted 11 they would be making a mistake.

I tried using this code as the default of the textbox:
Expand|Select|Wrap|Line Numbers
  1. nz(DCount("Fish_ID","tbl_Specimen_Fish_Entrainment","Specimen_ID = " & [Specimen_ID]),0)
but no go.

I also tried using the code on the afterupdate event of the subform:
Expand|Select|Wrap|Line Numbers
  1. Dim CountFish As Integer
  2. Private Sub Form_AfterUpdate()
  3. CountFish = Nz(DCount("Fish_ID", "tbl_Specimen_Fish_Entrainment", "Specimen_ID = " & [Specimen_ID]), 0)
  4. End Sub
again no go. Any ideas?

Oh and I am using Fish_ID in the code but it is not one of the column in my datasheet view of the subform. Does that matter?

One last thing - even though I set a default I still need the count textbox to be editable. In other words, it may count 12 records on the subform but the user may actually have 47 fish total and just not enough time to record all the data on the subform, if that makes sense.

Thanks!
May 11 '07
51 5645
AccessIdiot
493 256MB
This seems to be working! Of course, I haven't handed it over to my db users yet. I'm sure they'll find a way to break it. :-)

Thanks for seeing this through Denburt. I'm not sure I understand how it all works but I am glad it is working!
Jun 5 '07 #51
Denburt
1,356 Expert 1GB
Glad it is working WHEW (wipes the sweat off the brow). :) Glad I could help, when they break it just let us know.
Jun 5 '07 #52

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

Similar topics

7
by: jdph40 | last post by:
I posted this problem previously and received excellent help from Wayne Morgan. However, I still have an unanswered question. My form (frmVacationWeeks) is opened from the OnClick event of a...
1
by: Megan | last post by:
Hi Everybody- I've been reading some of the posts about DCOUNT, and I haven't yet found an answer; so, I'm posting this question. I have a report that I'm trying to use DCOUNT on to compute...
4
by: Will | last post by:
Hi, I had a DCount within a module on records in a table where CustSuffix = 0. I now need to DCount where CustSuffix = 0 and the type of cost Suffix (Suffix in table) = G. I can't get both...
6
by: Mike Conklin | last post by:
This one really has me going. Probably something silly. I'm using dcount for a report to determine the number of different types of tests proctored in a semester. My report is based on a...
2
by: Paul T. RONG | last post by:
Hi, I have a problem with DCount, the following code doesn't work: DCount("", "qryOrder", "( = Me! AND = 'drink')" > 0 Please help. Thank you.
3
by: BerkshireGuy | last post by:
I am having difficulty with using the Dcount function. I am trying to return the number of records from qryIndividualFeedbackDetail where the TimelyManner field is set to 4. So, in the new...
2
by: Kaspa | last post by:
Hello I am trying to create dcount field but is not working I have tried every way possible and I can't get it to work. here is my code: =Dcount("","qryTotalscratched"," in (6,7,8,9) and ...
1
by: highbulp | last post by:
I'm trying to use the DCount() function in the Report Header of a new report. The ReportSource for this report is a parametered Query. My DCount call looks like: DCount("","","=1") where...
2
by: Wingz | last post by:
Hiya, Fairly new to Access and was wondering what the best way to perform Dcounts on groups in an Access report. For example, I have 10 employees and the different instances of jobs they can...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
marktang
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,...
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...

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.