need directionon "cancelled previous operation" error

M

Mark Kubicki

I need to check if any records exist for an entry before continuing code,
so, I have this quick sub...
which returns the error: "You cancelled previous operation"; I do not know
what I should be looking for to correct it

Private Sub cmdUpdateAtMasterDatabase_Click()
varX = DLookup("[ManufacturerName]", "Manufacturers", _
"[ManufacturerName] = " & Forms![Spec].[Manufacturer])
If IsNull(varX) Then
responce = MsgBox("This manufacturer is not in the master list,
and cannot be updated", vbInformation & vbOK, "Manufacturer Not Found")
Exit Sub
End If
Me.lblSelectRepAgency.Visible = True
Me.cboSelectRepAgency.Visible = True
etc...

thanks in advance,
mark
 
D

Douglas J. Steele

That very misleading error message can occur if you mistyped a name in the
DLookup statement.

However, assuming that ManufactureName is a text field, I suspect that the
problem is the fact that you forgot to enclose the value being passed in
quotes:

varX = DLookup("[ManufacturerName]", "Manufacturers", _
"[ManufacturerName] = """ & Forms![Spec].[Manufacturer] & """")

That's three double quotes in a row before the reference to the control on
the form, and four double quotes in a row after.
 
M

Mark Kubicki

thnx



Douglas J. Steele said:
That very misleading error message can occur if you mistyped a name in the
DLookup statement.

However, assuming that ManufactureName is a text field, I suspect that the
problem is the fact that you forgot to enclose the value being passed in
quotes:

varX = DLookup("[ManufacturerName]", "Manufacturers", _
"[ManufacturerName] = """ & Forms![Spec].[Manufacturer] & """")

That's three double quotes in a row before the reference to the control on
the form, and four double quotes in a row after.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Mark Kubicki said:
I need to check if any records exist for an entry before continuing code,
so, I have this quick sub...
which returns the error: "You cancelled previous operation"; I do not
know what I should be looking for to correct it

Private Sub cmdUpdateAtMasterDatabase_Click()
varX = DLookup("[ManufacturerName]", "Manufacturers", _
"[ManufacturerName] = " & Forms![Spec].[Manufacturer])
If IsNull(varX) Then
responce = MsgBox("This manufacturer is not in the master
list, and cannot be updated", vbInformation & vbOK, "Manufacturer Not
Found")
Exit Sub
End If
Me.lblSelectRepAgency.Visible = True
Me.cboSelectRepAgency.Visible = True
etc...

thanks in advance,
mark
 

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