When you're querying against a text field, you need to enclose the value in
quotes. You can do this using single quotes, but you'll run into problems if
your string contains an apostrophe in it (O'Reilly), so my usual advice is
to use Chr$(34):
DSum("[tot]","[Query1]"," Expr1= " & [Expr1] & "AND MC= " & Chr$(34) & [MC]
& Chr$(34))
If you're not concerned about apostrophes:
DSum("[tot]","[Query1]"," Expr1= " & [Expr1] & "AND MC= '" & [MC] & "'")
Exagerated, so that the quotes are easier to see:
DSum("[tot]","[Query1]"," Expr1= " & [Expr1] & "AND MC= ' " & [MC] & " ' ")
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(No private e-mails, please)
"Alex" <ge****@yas1.fr eeserve.co.uk> wrote in message
news:b7******** *************** **@posting.goog le.com...
Acc 97
Hi,
I have the following in my query which works well if it is all set to
numbers on table design.
But what I want to do is where it states MC (short for machine name) use
the actual machine name of which there are 5 off. therefore, on the table
design I flick it over to text mode.
the query throws a wobbler! and all I get is Error!!
would a kind knowledgeable sole, show me how I need to modify this, so
that I can use Text setting only the end parts as identified as "MC="&[MC]
Note this works OK if all is numeric
DSum("[tot]","[Query1]"," Expr1="& [Expr1]& "AND " & " " & "MC=" &[MC])
Thanks, Alex