DMax Problem

A

Anthony Viscomi

Everytime I run the following from a "Click Event:

Private Sub Command32_Click()
Dim intPos As Double

intPos = DMax("[Position]", "tbl_OrderB", "[ID_B] = Me.ID_C")
Me.Position = intPos + 0.1

End Sub

I receive the Run-time error '2001'
You canceled the previous operation.

What am I doing wrong? I want ID_B in the tbl_OrderB table to be = to ID_C
on the form where the event is taking place and provide me with the Max
value.

Thanks!
Anthony
 
K

Ken Snell [MVP]

Try this:

intPos = DMax("[Position]", "tbl_OrderB", "[ID_B] = " & Me.ID_C)

The error you're getting is caused by the fact that the function doesn't
know what to do with Me.ID_C when it's thinking that it's a value as
written. Instead, what you do is concatenate the value into the string,
using the expression above.
 

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