That is not correct. DLook does not return a number of records, it returns
one value from the field specified.
First sentence of DLookup in VBA Help:
You can use the DLookup function to get the value of a particular field from
a specified set of records (a domain).
And further on:
If more than one field meets criteria, the DLookup function returns the
first occurrence. You should specify criteria that will ensure that the field
value returned by the DLookup function is unique. You may want to use a
primary key value for your criteria, such as [EmployeeID] in the following
example, to ensure that the DLookup function returns a unique value
So how do you get a count from DLookup?
--
Dave Hargis, Microsoft Access MVP
Maurice said:
I know what you mean but if you create a query as stated you would only get
one field with a total count in it. Then when you use a dlookup you would
only get one value returned being the total count of the records as created
by the query...
--
Maurice Ausum
:
DLookup will not return a number of records. As written, it will return the
first value it finds in the ID field in the query.
The correct method would be
=DCount("*", "Query Name","[ID] = " & Me.txtID)
--
Dave Hargis, Microsoft Access MVP
:
Try it this way:
Create a query with the needed table. Add the id-field to the grid. Total it
by Count. Save the query and on the form you place an unbound field.
In VBA you can do a Dlookup for the one field in the query like
Dlookup("id","name of your query")
This will display the amount of records.
hth
--
Maurice Ausum
:
I need to show a count of records for doc on main form. Doc info is on main
form and list of pts is on subform. I have entered an unbound text box on
the main form and have tried DCount, ABSSum and Count all I get is 0. This
is what I have entered: =DCount([ID]) or ABS(Sum([myfrom].[ID]) and
=Count([ID]). Thank you in advance for any help you can provide. Thank you.