By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,476 Members | 1,553 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,476 IT Pros & Developers. It's quick & easy.

Error: You cancelled the previous operation

100+
P: 111
Some of this may look familar to some of you, as part of it was posted previously. As i got farther along, i realized i was missing part of it and had to go back and redesign. The code is not fully complete so i just commented the lines that are not relevent to the issue. When the code is run, i'm getting an error that says "You cancelled the previous operation". First i was getting an error of "invalid use of null" and added the Nz functions in, leaving me with the error im at now. Can someone please help?

Expand|Select|Wrap|Line Numbers
  1. Private Sub btnCabin_Click()
  2. On Error GoTo Err_btnCabin_Click
  3.  
  4.     Dim stDocName As String
  5.     Dim stLinkCriteria As String
  6.  
  7.     Dim intInside As Integer
  8.     Dim intInside2 As Integer
  9.     Dim intInside3  As Integer
  10.     Dim intInside4  As Integer
  11.  
  12.     'Dim intOV As Integer
  13.     'Dim intBalc As Integer
  14.     Dim SQL As String
  15.     Dim strInsideCatA As String
  16.     Dim strInsideCatB As String
  17.     Dim strInsideCatC As String
  18.     Dim strInsideCatD As String
  19.  
  20.     stDocName = "frmNewCabins"
  21.  
  22.     stLinkCriteria = "[GroupNumber]=" & "'" & Me![GroupNumber] & "'"
  23.     DoCmd.OpenForm stDocName, , , stLinkCriteria
  24.  
  25.     strInsideCatA = Nz([Forms]![frmNewCabins]![InsideCat], "")
  26.     strInsideCatB = Nz([Forms]![frmNewCabins]![InsideCatB], "")
  27.     strInsideCatC = Nz([Forms]![frmNewCabins]![InsideCatC], "")
  28.     strInsideCatD = Nz([Forms]![frmNewCabins]![InsideCatD], "")
  29.  
  30.     intInside = DCount("tblManifest.[ID]", "tblManifest", "tblManifest.[Category] = 'Inside' AND tblManifest.[CategoryNum] = strInsideCatA AND [GroupNumber]=" & "'" & Me![GroupNumber] & "'")
  31.     intInside2 = DCount("tblManifest.[ID]", "tblManifest", "tblManifest.[Category] = 'Inside' AND tblManifest.[CategoryNum] = strInsideCatB AND [GroupNumber]=" & "'" & Me![GroupNumber] & "'")
  32.     intInside3 = DCount("tblManifest.[ID]", "tblManifest", "tblManifest.[Category] = 'Inside' AND tblManifest.[CategoryNum] = strInsideCatC AND [GroupNumber]=" & "'" & Me![GroupNumber] & "'")
  33.     intInside4 = DCount("tblManifest.[ID]", "tblManifest", "tblManifest.[Category] = 'Inside' AND tblManifest.[CategoryNum] = strInsideCatD AND [GroupNumber]=" & "'" & Me![GroupNumber] & "'")
  34.  
  35.  
  36.  
  37.     'intOV = DCount("tblManifest.[ID]", "tblManifest", "tblManifest.[Category] = 'OV' AND [GroupNumber]=" & "'" & Me![GroupNumber] & "'")
  38.     'intBalc = DCount("tblManifest.[ID]", "tblManifest", "tblManifest.[Category] = 'Balcony' AND [GroupNumber]=" & "'" & Me![GroupNumber] & "'")
  39.  
  40.     Forms![frmNewCabins]![InsideRemain] = Forms![frmNewCabins]![InsideAmt] - intInside
  41.     Forms![frmNewCabins]![InsideRemainB] = Forms![frmNewCabins]![InsideAmtB] - intInside2
  42.     Forms![frmNewCabins]![InsideRemainC] = Forms![frmNewCabins]![InsideAmtC] - intInside3
  43.     Forms![frmNewCabins]![InsideRemainD] = Forms![frmNewCabins]![InsideAmtD] - intInside4
  44.  
  45.  
  46.     'Forms![frmNewCabins]![OVRemain] = Forms![frmNewCabins]![OVAmt] - intOV
  47.     'Forms![frmNewCabins]![BalconyRemain] = Forms![frmNewCabins]![BalconyAmt] - intBalc
  48.  
  49.  
  50. Exit_btnCabin_Click:
  51.     Exit Sub
  52.  
  53. Err_btnCabin_Click:
  54.     MsgBox Err.Description
  55.     Resume Exit_btnCabin_Click
  56.  
  57. End Sub
Sep 13 '07 #1
Share this Question
Share on Google+
7 Replies


100+
P: 111
ok i've narrowed it down and realized its my syntax. Can someone help me with the correct syntax for this part of my code:

Expand|Select|Wrap|Line Numbers
  1. intInside = DCount("tblManifest.[ID]", "tblManifest", "tblManifest.[Category] = 'Inside' AND tblManifest.[CategoryNum] = strInsideCatA  AND [GroupNumber]=" & "'" & Me![GroupNumber] & "'")
i know that's the part thats giving me my error, but i dont know the correct syntax.

Thanks!
Sep 13 '07 #2

MGrowneyARSI
P: 90
try
intInside = DCount("tblManifest.[ID]", "tblManifest", "tblManifest.[Category] = 'Inside' AND tblManifest.[CategoryNum] = strInsideCatA AND [GroupNumber]= Me![GroupNumber] ")
or
intInside = DCount("tblManifest.[ID]", "tblManifest", "tblManifest.[Category] = "& 'Inside' AND tblManifest.[CategoryNum] = strInsideCatA AND [GroupNumber]= Me![GroupNumber])

This is the syntax for numaric values but not sure if it will work with what your doing here. worth a shot though
Sep 13 '07 #3

100+
P: 111
the code worked fine until i added the part that i bolded above - thats the part that needs the syntax corrected.
Sep 13 '07 #4

Expert 100+
P: 296
the code worked fine until i added the part that i bolded above - thats the part that needs the syntax corrected.
Not sure how to refer to the strInsideCatA variable, but what if you were to try replacing it with the expression you have assigned to it: Nz([Forms]![frmNewCabins]![InsideCat], "")?
Sep 13 '07 #5

100+
P: 111
This gives me a syntax error:

Expand|Select|Wrap|Line Numbers
  1. intInside = DCount("tblManifest.[ID]", "tblManifest", "tblManifest.[Category] = 'Inside' AND tblManifest.[CategoryNum] = Nz([Forms]![frmNewCabins]![InsideCat], "") AND [GroupNumber]=" & "'" & Me![GroupNumber] & "'")
Sep 13 '07 #6

100+
P: 111
Ok i figured it out, but im not really sure why....i just kind of mimicked the same syntax for the third part of the AND statement where GroupNumber is.

this is what i have that works:

Expand|Select|Wrap|Line Numbers
  1. intInside = DCount("tblManifest.[ID]", "tblManifest", "tblManifest.[Category] = 'Inside' AND tblManifest.[CategoryNum] =" & "'" & Nz([Forms]![frmNewCabins]![InsideCat], "") & "' AND [GroupNumber]=" & "'" & Me![GroupNumber] & "'")
Sep 13 '07 #7

Expert 100+
P: 296
Ok i figured it out, but im not really sure why....i just kind of mimicked the same syntax for the third part of the AND statement where GroupNumber is.

this is what i have that works:

Expand|Select|Wrap|Line Numbers
  1. intInside = DCount("tblManifest.[ID]", "tblManifest", "tblManifest.[Category] = 'Inside' AND tblManifest.[CategoryNum] =" & "'" & Nz([Forms]![frmNewCabins]![InsideCat], "") & "' AND [GroupNumber]=" & "'" & Me![GroupNumber] & "'")
The quotes can be quite confusing, but I'm glad you got it working.
Sep 13 '07 #8

Post your reply

Sign in to post your reply or Sign up for a free account.