Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

#Name? - Arrrggghhh - Won't Count [Text Field - Access 2007] 2

Status
Not open for further replies.

Maillme

Technical User
Mar 11, 2003
186
NL
Hi there,

I'm trying to get a simple count of records that are displayed in my list box - these records query 3 tables for their data (data displays correctly).

I have the following code on the control source property of my text box (participant_count):

=DCount([“attendance_id”],[“tbl_attendances”],[“session_id]=[”] & [Forms]![frm_session_check_in]![cmbsessions].[Value])

My text field only displays:

#Name?
 
sorry, my text box is actually called:

participant_number

Neil
 
=DCount("attendance_id","tbl_attendances","session_id=" & [Forms]![frm_session_check_in]![cmbsessions])

get rid of all the square brackets. they are in the wrong places. if you need them at all, they would go inside the quotes.

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
 
Hi Ginger,

thanks for the response - unfortunatelly im now getting the following error appearing in my text box:

#Error

:( - any ideas?

thanks again,
Neil
 
if you put in a number vs. the form reference, does it work?

=DCount("attendance_id","tbl_attendances","session_id=7")

make sure instead of the 7, you put in a valid Session_ID.
are the field names spelled correctly?
is the table name correct?

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
 
[blue][tt]#Error[/tt][/blue] is a wonderfully generic indicator. You need to isolate elements to find the trouble maker.

Move the DCount function to a query instead of a form and try to make it work there.

The form reference [blue][tt][Forms]![frm_session_check_in]![cmbsessions][/tt][/blue] is bound to be hazardous. Substitute in a number. If that works, then perhaps the form reference is off. But the problem could be elsewhere, for example with the comparison string (e.g., congruent data types, appropriate comparison operator).

[purple]If we knew what it was we were doing, it would not be called
research [blue]database development[/blue], would it? [tab]-- Albert Einstein[/purple]​
 
How are ya Maillme . . .

I'm confused! [surprise] You say
Maillme said:
[blue]I'm trying to get a simple count of records that are displayed in my list box ...[/blue]
Yet your looking at a table to thru [blue]DCount[/blue] to get your answer! [surprise]

To get the number of records displayed in a listbox I'd use the following
Code:
[blue]= [[purple][B][I]YourListboxName[/I][/B][/purple]].[ListCount][/blue]
[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Hi Aceman,

I used your code - which gets rid of my errors, but unfortunately does not display a value :( (blank txt box)

any idea why?

many thanks,
Neil
 
Maillme, i suggest you post your code.

[purple]If we knew what it was we were doing, it would not be called
research [blue]database development[/blue], would it? [tab]-- Albert Einstein[/purple]​
 
... and where are you placing the code?

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
[blue]?[/blue] [surprise]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
A black hole took him. That explains the expanding blankness! Thanks tho for that great reminder, the ListCount property.

[purple]If we knew what it was we were doing, it would not be called
research [blue]database development[/blue], would it? [tab]-- Albert Einstein[/purple]​
 
Scary - I couldn't imagine being eaten alive by a black hole.
[wink]

--

"If to err is human, then I must be some kind of human!" -Me
 
Hi All,

sorry for delay. Internet problems.

My code is on the Control Source of the text box and is as follows:

=[session_list].[ListCount]

many thanks,
Neil
 
Create a function like this:
Code:
Function getParticipantCount()
getParticipantCount = Me![session_list].ListCount
End Function
And now the ControlSource:
= getParticipantCount()

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top