Syntax Problem - DMax

C

croy

Some snippets of code I have:

strWhere = "[IvSurvId] = " & Me.Parent![IvSurvId]

StrWhere2 = "[IvSurvId] = " & Me.Parent![IvSurvId] _
" And [IvPage] = " & Me![txtIvPage].Value

and it's almost working for me.

Id like to change the last part of strWhere2, making the
line:

strWhere2 = "[IvSurvId] = " & Me.Parent![IvSurvId] _
& " And [IvPage] = "
(shifting to plain English here)
"The highest value of IvPage for strWhere" or...
DMax("IvPage", "tblIvDetail", strWhere)

.... except in a syntax that works... ;)

I've tried about everything I can think of.

Any takers?
 
D

Douglas J. Steele

Sounds as though you're looking for

strWhere2 = "[IvSurvId] = " & Me.Parent![IvSurvId] _
& " And [IvPage] = " & DMax("IvPage", "tblIvDetail", strWhere)

That assumes, of course, that both IvSurvId and IvPage are numeric fields.
 
G

Graham Mandeno

Hi Croy

Have you tried concatenating the DMax expression with your string just as
you have it?

strWhere2 = strWhere & " And [IvPage] = " _
& DMax("IvPage", "tblIvDetail", strWhere)

That should do the trick. The syntax looks fine to me.
 
C

croy

Sounds as though you're looking for

strWhere2 = "[IvSurvId] = " & Me.Parent![IvSurvId] _
& " And [IvPage] = " & DMax("IvPage", "tblIvDetail", strWhere)

That assumes, of course, that both IvSurvId and IvPage are numeric fields.

Yup, they are.

Perfect! Thank you.
 
C

croy

Hi Croy

Have you tried concatenating the DMax expression with your string just as
you have it?

strWhere2 = strWhere & " And [IvPage] = " _
& DMax("IvPage", "tblIvDetail", strWhere)

That should do the trick. The syntax looks fine to me.

Thanks Graham.
 

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