More Dsum problems

G

Guest

I am trying to have a text box called
NumberOfRemainingPlaces, which is an unbound control, do
the
following calculation:

Return the total number of bookings from
tblbookings.numberOfPeople where the holiday number = the
holiday number from frmBookings.HolidayRef

tblbookings.numberofpersons is a long int.

From a note I have already posted I have got this far:

=DSum("[NumberOfPeople"]","tblBookings","[HolidayNumber]
= " &
Me![HolidayRef])

however this is giving me a #Name error.

Here is the dsum with the proper names:

=DSum("[NumberOfpersons"]","tblBookings","[HolidayRef]
= " & Me![HolidayRef])

I have also tried:

=DSum("[NumberOfPeople]","tblBookings","[HolidayNumber]
= " & Me![HolidayRef])

As this would seem to be correct with no joy. I also
dont understand why some text box names have brackets and
quotes and some dont.

Thanks for any help given.
 
N

Nikos Yannacopoulos

The syntax in:

=DSum("[NumberOfPeople]","tblBookings","[HolidayNumber]= " &
Me![HolidayRef])
(all in one line!)

looks correct, provided the table / field / control names are correct,
and field HolidayNumber in tblBookings is numeric! If, ins psite of its
name, it happens to be text, then the syntax must change to:

=DSum("[NumberOfPeople]","tblBookings","[HolidayNumber]= '" &
Me![HolidayRef]) & "'"
(again, all in one line)

Quotes denote text strings; Domain Aggregate functions like DSum require
their arguments to be text, thus the quotes. Square brackets denote
Access objects (in this case, fields). This is too general, of course,
and may vary for different objects (e.g. forms / reports vs. VB code).
It is impossible to explain exhaustively in this context, it takes some
reading and / or experience before it all becomes clear.

HTH,
Nikos
 

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

Similar Threads


Top