DMax Problem

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