Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How Do I Cancel Combo Update???

Status
Not open for further replies.

Shokoya

IS-IT--Management
Aug 4, 2003
81
GB

Hi Guys,

Does anybody know the code for canceling a change made using a combo box. I would like a message to appear before the Update. If the user opts for 'Yes' then the change should be registered. If the user selects 'No', the combo value should 'roll back' to its original value.

Tried using the following code, but it doesn't like the .CancelUpdate line of code.

Dim strSQL As String, X As Integer, astr As String

If IsNull(Me.Client_Id) Then
Exit Sub
Else
astr = Me.Client_Id

X = MsgBox("You are about to change an existing Client records. Click on 'Yes' to continue or", vbYesNo)
If X = vbYes Then
Exit Sub
Else
.CancelUpdate
End If


Any suggestions will be greatly appreciated!

[cheers]
 
Hi

Before update event looks promising to me

Private Sub Client_Id_BeforeUpdate(Cancel As Integer)
Dim strSQL As String, X As Integer, astr As String

If IsNull(Me.Client_Id) Then
Exit Sub
Else
astr = Me.Client_Id

X = MsgBox("You are about to change an existing Client records. Click on 'Yes' to continue or", vbYesNo)
If X = vbYes Then
Exit Sub
Else
cancel = True
End If

End Sub

it has a Cancel

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Thanx 4 that Ken,

Tried the code including the Cancel = True...however, it does not roll back the combo value to its original value. Any suggestions??

[cheers] again
 
Hi

Is the Client_d the combo

is the Combo bound

You are trying to roll back the .value and not a value added to the combo box list aren't you

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Sorry....

Combo30 is the combo box....the value is stored in Client_Id.

If the user changes the text value in Combo30, the value in Client_Id will change also.

What I'm trying to do is prompt the user before they make such a change.

However, its seems that the BeforeUpdate event only runs after the user has made a change in the combo...bit weird I'd say??? So that means if the user decide they don't want to change an existing record, the system should automatically undo any change to the combo box value.

[cheers]
 
Hi

Nothing weird about it you just need the code in the before update event of the combo (eg Comb30), not Client_id

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Hi,
Thats where i have put the code

Sorry...didn't past the first line of code intially;


Private Sub Combo30_BeforeUpdate(Cancel As Integer)
Dim strSQL As String, ans As Integer, astr As String
If IsNull(Me.Client_Id) Then
Exit Sub
Else
ans = MsgBox("You are about to change an existing Client record. Click on 'Yes' to continue or 'No' to exit", vbYesNo)
If ans = vbYes Then
Exit Sub
Else
Cancel = True
End If
End If
End Sub


[cheers]
 
4got to add;

The Control Source for 'Combo30' is 'Client_Id'

Thanx for ur tyme

[cheers]
 
This was driving my crazy as well. I have the same stucture that you have.

I finally got it to work by using:

Private Sub Combo30_BeforeUpdate(Cancel As Integer)
Dim strSQL As String, ans As Integer, astr As String
If IsNull(Me.Client_Id) Then
Exit Sub
Else
ans = MsgBox("You are about to change an existing Client record. Click on 'Yes' to continue or 'No' to exit", vbYesNo)
If ans = vbYes Then
Exit Sub
Else
Cancel = True
*** Me.Combo30.Undo ***
End If
End If
End Sub

Hope this helps.

Rene'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top