beforeupdate event undo change to a combo box?

jackie77

Jackie
Local time
Today, 12:46
Joined
Jul 18, 2007
Messages
85
Hi all

I'm working on a bit of code that before a combobox is changed checks with the user to confirm that they want the change to go ahead, if yes a recorded is added to a table

this all work fine apart from if no is selected - I am trying to get the combobox to undo the change however when you select no the msgbox pops up fine but the combobox does not undo

can't see where I'm going wrong I thought undo worked for comboboxes :confused:

Any help would be appreciated

Cheers
Jackie

Code:
      ' Displays a message box with the yes and no options.
      Response = MsgBox(prompt:="Do you wish to change the status of this Job? 'Yes' or 'No'.", Buttons:=vbYesNo)
      ' If Yes button selected
      If Response = vbYes Then
      
                    Comment = "To: " & Me.StatusTemp1 & " From: " & Me.StatusID.Column(1)
      
                        CurrentDb.Execute "INSERT INTO Communication ([CommunicationType],[Date],[JobID], [StaffID], [MethodReportedID], [Notes])VALUES ('24', Now(), " & JobID & ", " & StaffID & ", '6', '" & Comment & "');"
                        MsgBox "The Status has been changed" & Chr(13) & Chr(10) & " and the record has been updated successfully!"
                        
 Else
   ' If no button was selected.
            Me.StatusID.Undo
             MsgBox "Status is PLEASE NOTE - The account status has not been changed!!" & Me.StatusID & "  " & Me.StatusTemp1 & "  " & Me.StatusTemp2
             
    End If
End Sub
 
You need

Cancel = True
 
AHHH serious blonde moment of course I need cancel = true lol
stupid question I'm even embarrassed to say I looked at this code for ages lol

Cheers
Paul
 
No problem Jackie! Sometimes we all need an extra pair of eyes.
 

Users who are viewing this thread

Back
Top Bottom