debug error

  • Thread starter Dimitris Nikolakakis
  • Start date
D

Dimitris Nikolakakis

I have a form FOfferTransform and I have put a button to do the following:
*******************************************************************
Dim x As Integer
x = DCount("OrderID", "Orders", "[OrderID] = Forms![
FOfferTransform]!Text3")

If x <> 0 Then

Dim Response
Response = MsgBox("my message!", vbOKOnly, "my message")
Me.ActiveControl.Undo

Else

DoCmd.SetWarnings False
DoCmd.OpenQuery "qOfferTransform_1", acViewNormal, acEdit
DoCmd.OpenQuery "qOfferTransform_2", acViewNormal, acEdit
DoCmd.OpenQuery "qOfferTransform_3", acViewNormal, acEdit
DoCmd.Close acForm, "FOrders"
DoCmd.SetWarnings True

Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "FOrders"
stLinkCriteria = "[OrderID]+[TypeID]=" & "'" & Me![Text3] + "ORD" & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

DoCmd.Close acForm, "FOfferTransform"

End If
*******************************************************************

I get debug error:

Run-time error 2001:
You canceled the previous operation.

If I click debug the cursor is no line:
x = DCount("OrderID", "Orders", "[OrderID] = Forms![
FOfferTransform]!Text3")

If I remove the 'IF ... ... Then ... ... Else' and I just put the
...............

DoCmd.SetWarnings False
DoCmd.OpenQuery "qOfferTransform_1", acViewNormal, acEdit
DoCmd.OpenQuery "qOfferTransform_2", acViewNormal, acEdit
DoCmd.OpenQuery "qOfferTransform_3", acViewNormal, acEdit
DoCmd.Close acForm, "FOrders"
DoCmd.SetWarnings True

Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "FOrders"
stLinkCriteria = "[OrderID]+[TypeID]=" & "'" & Me![Text3] + "ORD" & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

DoCmd.Close acForm, "FOfferTransform"

............. it works fine.


Thanks in advance
Dimitris Nikolakakis
 
T

tina

well, assuming that the problem really IS in the DCount expression
(sometimes the highlighted line of code isn't the actual problem), try

x = DCount(1, "Orders", "OrderID = " & Me!Text3)

the above assumes that OrderID is a number data type. if it's a Text data
type, try

x = DCount(1, "Orders", "OrderID = '" & Me!Text3 & "'")

hth
 

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

Similar Threads


Top