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? - Private Sub btnCabin_Click()
-
On Error GoTo Err_btnCabin_Click
-
-
Dim stDocName As String
-
Dim stLinkCriteria As String
-
-
Dim intInside As Integer
-
Dim intInside2 As Integer
-
Dim intInside3 As Integer
-
Dim intInside4 As Integer
-
-
'Dim intOV As Integer
-
'Dim intBalc As Integer
-
Dim SQL As String
-
Dim strInsideCatA As String
-
Dim strInsideCatB As String
-
Dim strInsideCatC As String
-
Dim strInsideCatD As String
-
-
stDocName = "frmNewCabins"
-
-
stLinkCriteria = "[GroupNumber]=" & "'" & Me![GroupNumber] & "'"
-
DoCmd.OpenForm stDocName, , , stLinkCriteria
-
-
strInsideCatA = Nz([Forms]![frmNewCabins]![InsideCat], "")
-
strInsideCatB = Nz([Forms]![frmNewCabins]![InsideCatB], "")
-
strInsideCatC = Nz([Forms]![frmNewCabins]![InsideCatC], "")
-
strInsideCatD = Nz([Forms]![frmNewCabins]![InsideCatD], "")
-
-
intInside = DCount("tblManifest.[ID]", "tblManifest", "tblManifest.[Category] = 'Inside' AND tblManifest.[CategoryNum] = strInsideCatA AND [GroupNumber]=" & "'" & Me![GroupNumber] & "'")
-
intInside2 = DCount("tblManifest.[ID]", "tblManifest", "tblManifest.[Category] = 'Inside' AND tblManifest.[CategoryNum] = strInsideCatB AND [GroupNumber]=" & "'" & Me![GroupNumber] & "'")
-
intInside3 = DCount("tblManifest.[ID]", "tblManifest", "tblManifest.[Category] = 'Inside' AND tblManifest.[CategoryNum] = strInsideCatC AND [GroupNumber]=" & "'" & Me![GroupNumber] & "'")
-
intInside4 = DCount("tblManifest.[ID]", "tblManifest", "tblManifest.[Category] = 'Inside' AND tblManifest.[CategoryNum] = strInsideCatD AND [GroupNumber]=" & "'" & Me![GroupNumber] & "'")
-
-
-
-
'intOV = DCount("tblManifest.[ID]", "tblManifest", "tblManifest.[Category] = 'OV' AND [GroupNumber]=" & "'" & Me![GroupNumber] & "'")
-
'intBalc = DCount("tblManifest.[ID]", "tblManifest", "tblManifest.[Category] = 'Balcony' AND [GroupNumber]=" & "'" & Me![GroupNumber] & "'")
-
-
Forms![frmNewCabins]![InsideRemain] = Forms![frmNewCabins]![InsideAmt] - intInside
-
Forms![frmNewCabins]![InsideRemainB] = Forms![frmNewCabins]![InsideAmtB] - intInside2
-
Forms![frmNewCabins]![InsideRemainC] = Forms![frmNewCabins]![InsideAmtC] - intInside3
-
Forms![frmNewCabins]![InsideRemainD] = Forms![frmNewCabins]![InsideAmtD] - intInside4
-
-
-
'Forms![frmNewCabins]![OVRemain] = Forms![frmNewCabins]![OVAmt] - intOV
-
'Forms![frmNewCabins]![BalconyRemain] = Forms![frmNewCabins]![BalconyAmt] - intBalc
-
-
-
Exit_btnCabin_Click:
-
Exit Sub
-
-
Err_btnCabin_Click:
-
MsgBox Err.Description
-
Resume Exit_btnCabin_Click
-
-
End Sub
7 1429
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: - 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!
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
the code worked fine until i added the part that i bolded above - thats the part that needs the syntax corrected.
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], "")?
This gives me a syntax error: - intInside = DCount("tblManifest.[ID]", "tblManifest", "tblManifest.[Category] = 'Inside' AND tblManifest.[CategoryNum] = Nz([Forms]![frmNewCabins]![InsideCat], "") AND [GroupNumber]=" & "'" & Me![GroupNumber] & "'")
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: - intInside = DCount("tblManifest.[ID]", "tblManifest", "tblManifest.[Category] = 'Inside' AND tblManifest.[CategoryNum] =" & "'" & Nz([Forms]![frmNewCabins]![InsideCat], "") & "' AND [GroupNumber]=" & "'" & Me![GroupNumber] & "'")
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: - 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.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: daniel kern |
last post by:
Please help with the following issue.
I am trying to dump a table. My mysqldump command is:
mysqldump.exe -u xx -P xx --add-drop-table --quick --extended-insert
--result-file=xx "--where=cdrdate...
|
by: Jeff Pritchard |
last post by:
Has anybody had a problem with the SaveAsText function causing an error 'you
cancelled the previous operation'. I have some code that was previously
working fine, but now is giving this error. I am...
|
by: Richard Hollenbeck |
last post by:
I got this: "Error 2001 You cancelled the previous operation"
with this:
Private Sub courseCode_GotFocus()
Dim myDLookupResults As String
myDLookupResults = DLookup("courseID", "courses",...
|
by: John A. |
last post by:
I've received this error several times, and have only been able to get
around it by deleting the offending form(s) and importing them from backup -
Here's the sequence:
1. I'm editing a form or...
|
by: tara99 |
last post by:
I am trying to update a table. It works but at the end the system displays the following Message
"Previous operation cancelled"
Does any one know what does this means.
Thanks
|
by: Widge |
last post by:
I've been using code similar to this:
Option Compare Database
Private Sub Form_Open(Cancel As Integer)
SetFilter
|
by: noneedforthis |
last post by:
I'm a new user of Access/VB and ran in to this nasty wall.
(Access 2003, VB6.3, Windows XP)
Runtime Error 2001: You cancelled the previous operation.
The highlighted line is the one where the...
|
by: Asle |
last post by:
Hi,
I have a form called Customer and another form called Loan..
the Loan Details has to be entered every month until it is closed.
I have designed a form such that, the user goes to the...
|
by: paulw4 |
last post by:
I have the code below to run a query, that is created from a "fill in the blanks" form. I am now getting the error "You cancelled the previous operation"
Earlier when I got this I closed the...
|
by: jmoudy77 |
last post by:
I've got some vb code that gives me a "previous operation cancelled" error when I try and open the form as a subform in a tabbed control. When I open the form itself I don't get the error. Does...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |