Syntax Problem - DMax

  • Thread starter Thread starter croy
  • Start date Start date
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?
 
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.
 
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.
 
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.
 
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.
 
Back
Top