Below is my code. Me.Confirmed is a checkbox. Sometimes the cancel at line 37 works when the user clicks "no", someetimes it doesn't.
Is this my fault or someting else? - Private Sub Confirmed_BeforeUpdate(Cancel As Integer)
-
If gcfHandleErrors Then On Error GoTo PROC_ERR
-
PushCallStack "ConfirmDeployment"
-
-
Dim strfield As String
-
strfield = Me.ConsultantID & ""
-
If StrPtr(strfield) = 0 Or Len(strfield) = 0 Then
-
MsgBox "Cannot confirm deployment as no Consultant has been selected", vbCritical, "title"
-
Me.Undo
-
Cancel = True
-
GoTo PROC_EXIT
-
End If
-
-
-
Dim Msg1, Style1, Title1, Response1
-
-
If Me.Confirmed = True Then
-
Msg1 = "Are you sure that you want to confirm deployment of consultant to this Job?"
-
Msg1 = Msg1 & vbCrLf & "Make sure this is what you want to do."
-
End If
-
-
If Me.Confirmed = False Then
-
Msg1 = "Are you sure that you want to cancel deployment of consultant to this Job?"
-
Msg1 = Msg1 & vbCrLf & "Make sure this is what you want to do."
-
End If
-
-
Style1 = vbYesNo + vbQuestion + vbDefaultButton2
-
Title1 = "Confirm "
-
-
Response1 = MsgBox(Msg1, Style1, Title1)
-
-
If Response1 = vbYes Then
-
GoTo PROC_EXIT
-
-
Else
-
Me.Undo
-
Cancel = True
-
GoTo PROC_EXIT
-
End If
-
-
-
PROC_EXIT:
-
PopCallStack
-
Exit Sub
-
-
PROC_ERR:
-
GlobalErrHandler
-
Resume PROC_EXIT
-
End Sub
1 2359
Below is my code. Me.Confirmed is a checkbox. Sometimes the cancel at line 37 works when the user clicks "no", someetimes it doesn't.
Is this my fault or someting else? - Private Sub Confirmed_BeforeUpdate(Cancel As Integer)
-
If gcfHandleErrors Then On Error GoTo PROC_ERR
-
PushCallStack "ConfirmDeployment"
-
-
Dim strfield As String
-
strfield = Me.ConsultantID & ""
-
If StrPtr(strfield) = 0 Or Len(strfield) = 0 Then
-
MsgBox "Cannot confirm deployment as no Consultant has been selected", vbCritical, "title"
-
Me.Undo
-
Cancel = True
-
GoTo PROC_EXIT
-
End If
-
-
-
Dim Msg1, Style1, Title1, Response1
-
-
If Me.Confirmed = True Then
-
Msg1 = "Are you sure that you want to confirm deployment of consultant to this Job?"
-
Msg1 = Msg1 & vbCrLf & "Make sure this is what you want to do."
-
End If
-
-
If Me.Confirmed = False Then
-
Msg1 = "Are you sure that you want to cancel deployment of consultant to this Job?"
-
Msg1 = Msg1 & vbCrLf & "Make sure this is what you want to do."
-
End If
-
-
Style1 = vbYesNo + vbQuestion + vbDefaultButton2
-
Title1 = "Confirm "
-
-
Response1 = MsgBox(Msg1, Style1, Title1)
-
-
If Response1 = vbYes Then
-
GoTo PROC_EXIT
-
-
Else
-
Me.Undo
-
Cancel = True
-
GoTo PROC_EXIT
-
End If
-
-
-
PROC_EXIT:
-
PopCallStack
-
Exit Sub
-
-
PROC_ERR:
-
GlobalErrHandler
-
Resume PROC_EXIT
-
End Sub
From the looks of the code, there are alot of variables that could cause you problems. The Main one that sticks out at me is the gcfHandleErrors . Since you're conditionally setting the OnError Option, then you're going to have mixed results based on the value of gcfHandleErrors .
I don't understand the reason for conditionally setting the OnError, but if you can explain that to me and how the value of gcfHandleErrors is used, that may help me understand what you're trying to do.
The other thing that I have to comment about is it is NEVER good practice to Update the table and then ask, is this what you really wanted to do?
That may be MOST of your problem there. Just keep in mind that ask before making any changes to the data, will always help you when it comes to dealing with customers that may no know your interface that well.
Hope that helps,
Joe P.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: William Wisnieski |
last post by:
Hello Everyone,
Access 2000
I have a form with multiple pages on it. There is one text field
on the third page of the form that I need the user to
complete before leaving the form or moving to the next record.
So, in the BeforeUpdate event of the form itself I have the following code:
|
by: bob bob via AccessMonster.com |
last post by:
I'm sure this is a simple one.
I have a combo box that, when its data is changed, will trigger a second
form to open for input. If the operator declines input, I want the combo
box to return to its original value. The on change event is wrong for
this, since the new data has already been saved. As I undertand it, the
beforeupdate event...
|
by: simonmarkjones |
last post by:
I want to call a function which does this when the next record button
is pressed (calling it from before update)
if textboxes are empty then
Message box you must fill text box
|
by: PC Datasheet |
last post by:
In a form/subform I have an unbound combobox in the form header that sets
the value of a field in the subform so that it does not have to be entered
for each record. In the BeforeUpdate event of the combobox I have some code
to check the value against some criteria and if the new selected value fails
the criteria, I cancel the BeforeUpdate...
|
by: lorirobn |
last post by:
Hi,
I have a form with a continuous subform. I am working on putting
validations in for the subform's required fields. Being somewhat new
to Access (or rather, an antiquated mainframe programmer), I finally
figured out that the place to put the validations is in
Form_BeforeUpdate.
I have 2 questions:
1) once I determine there is an...
| |
by: tlyczko |
last post by:
I have a BeforeUpdate where I need to ensure that no matter what, the
first four fields on the form (one text box, 3 combo box lists) have
data entered in them before the user closes the form or before the user
moves off the form to a subform on the main form, regardless of whether
the end user even put focus to any of the four form fields.
...
|
by: Michael R |
last post by:
Dear users and experts,
An unbound combo box in my form is responsible for changing a city name for an update query that creates a temprorary table which the form uses as its record source.
In case that table is already created, and the combo box value is to be changed again, the temp. table needs to be deleted and the form needs to be...
|
by: thatguyNYC |
last post by:
Hello--
I have a form that lets the user edit the values in a lookup table. The form is bound to a table and has one textbox on it. The record nav buttons are enabled. On the top half of the form, I have a listbox showing all the records in the table. The user can double-click the listbox to jump to that record via this code: ...
|
by: ChipR |
last post by:
I have a generic AfterUpdate function applied to my 14 text boxes in a continuous subform, but I can't figure out the syntax to do BeforeUpdate with Cancel. Is this even possible?
Private Sub Form_Load()
Dim ctl As Control
For Each ctl In Me.Controls
If Left(ctl.Name, 3) = "Day" Then
'??? ctl.BeforeUpdate = "=CheckDay(""" &...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |