Display A Total Number of Records on a Form, This Should Be easy

I

Idgarad

Why this doesn't work I can't figure out. I have a query that returns
the count of a bunch of records. I have a billboard form of sorts that
has lots of buttons.

I add a text field, kill it's label and format it all nice to show a
total number of records (based off that query.) Yet for some reason
all I ever get is #Name?

All I need is to display the result of the query which is just a
simple:

SELECT Count(*) AS Expr1 FROM Table1;

I'm like what the hell?! This should be simple. But nothing. Zip,
zlich. It's sooo unbelievable simple via the web. How can I not be
able to just display the results? Am I retarded?
 
K

Ken Sheridan

You can either use the DLookup function to return the value from the query by
setting the ControlSource property of the text box to:

=DLookup("Expr1", "YourQuery")

or cut out the query altogether by using the DCount function:

=DCount("*", "Table1")

Ken Sheridan
Stafford, England
 
A

Arvin Meyer [MVP]

I've used:

=IIf([NewRecord],"New Record",[CurrentRecord] & " of " & Count(*))

as a controlsource of a textbox. and the following code in the Current Event
for a form:

If Me.NewRecord = True Then
Me!txtNavigate = "New Record"
Else
With Me.RecordsetClone
.Bookmark = Me.Bookmark
Me!txtNavigate = "Record " & .AbsolutePosition + 1 & " of " &
..RecordCount
End With
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top