Can't figure out error in simple dsum

D

deercreek

I have the following table test3.

RESERVATIONID Site SitePrice
101 RV2 $25.00
101 RV3 $25.00
102 RV4 $25.00
102 RV5 $25.00
104 RV10 $25.00

I created a query with the following dsum

DSum("SitePrice", "test3", "Reservationid = 101")

When I try to view query I get the following error. Anyone know whats
going on?

"Data type mismatch in criteria expression"
 
O

Ofer

If the RESERVATIONID field type is string, you should add a single quote
before and after the number

DSum("SitePrice", "test3", "Reservationid = '101'")
 
D

deercreek

That worked thanks! Now I would like to be able to get the reservation
id from the active record set on form. I tried the below code but It
dosn't return a total so /i am assuming its not getting id from form?

SiteTotal: DSum("SitePrice","test3","Reservationid = 'Forms!Taking
Reservations!ResrvationsID'")

Any Ideas?
 
O

Ofer

Try this

SiteTotal: DSum("SitePrice","test3","Reservationid = '" &
Forms!TakingReservations!ResrvationsID & "'")
 
F

fredg

That worked thanks! Now I would like to be able to get the reservation
id from the active record set on form. I tried the below code but It
dosn't return a total so /i am assuming its not getting id from form?

SiteTotal: DSum("SitePrice","test3","Reservationid = 'Forms!Taking
Reservations!ResrvationsID'")

Any Ideas?

Your original question was answered elsewhere.
Please do not multi-post. If you feel you must post the same question
to more than one newsgroup (and it's seldom necessary), cross-post by
adding each additional newsgroup in the To Newsgroups: box, separated
by a comma.
This way an answer in one newsgroup will be seen in each of the
others. More readers will see the response and learn, and less time
will be spent on duplicate answers.

See Netiquette at http://www.mvps.org/access

It's a great site to visit anyway.

***
Watch your spelling. You misspelled the field name ReservationsID
and you must concatenate the form value into the DSum Where clause,
otherwise Access is looking for the literal value 'forms![Taking
Reservations]!ResrvationsID'.

SiteTotal: DSum("SitePrice","test3","Reservationid = '" &
Forms![Taking Reservations]!ReservationsID & "'")

If you insist upon using a space within a field or table name, you
must surround that name with brackets. Keep it simple ...
"TakingReservations" is just as easy to read as "Taking Reservations".
Don't use spaces within object names or at least use an underscore
("Taking_Reservations").
 
D

deercreek

Well one other question. shouldn't I be able to use something similiar
as a criteria in another query?

"Reservationid = '" & Forms!TakingReservations!ResrvationsID & "'")

Seems like this should work then but it wont return a id?
 
F

fredg

Well one other question. shouldn't I be able to use something similiar
as a criteria in another query?

"Reservationid = '" & Forms!TakingReservations!ResrvationsID & "'")

Seems like this should work then but it wont return a id?

Do you mean as criteria for the query as a whole, then no, you do not
need to wrap the text in single quotes, nor concatenate it.

Where YourTable.ReservationID = forms![YourTable]![ReservationsID
will work just fine.

But within a function, i.e. DSum, DLookUp, etc, and within VBA, then
yes you do need to concatenate and wrap
 
Top