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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validation message in Combo box 2

Status
Not open for further replies.

knuckelhead

Technical User
Aug 8, 2002
228
US
I have a Combo box where you select an item. I would like to have a message after i pick a choice:

"You changed the Value; Do you want to change this? "

something like that.

Secondly, Will the person need to enter Y or N? Or is there another way? Below is my starter After Update.

====================================================
Private Sub cboBlendClassIDfilter_AfterUpdate()

xyz message

End Sub
====================================================

thanks
 
How are ya knuckelhead . . .

The BeforeUpdate event is perfect for this as the Cancel arguement can be used if the user selects no.
Code:
[blue]   Dim Msg As String, Style As Integer
   Dim Title As String, DL As String
   
   DL = vbNewLine & vbNewLine
   
   Msg = "You changed the Value; Do you want to change this?" & DL & _
         "Click 'Yes' to continue with the change." & DL & _
         "Click 'No' to abort the change . . ."
   Style = vbInformation + vbYesNo
   Title = "User Action Required! . . ."
   
   If MsgBox(Msg, Style, Title) = vbNo Then
      Cancel = True
   End If[/blue]

Calvin.gif
See Ya! . . . . . .
 
This is terrific so far. Can I ask one more thing? When I click on NO to cancel the change, i still need to hit the ESC key to make it revert back to the original entry.

I could add a phrase to hit NO and then ESC.

but i wonder if you have a slick way to just let the NO make the previous value go back (including if it were originally blank).

what do you think?
Knucklehead
 
If MsgBox(Msg, Style, Title) = vbNo Then
Cancel = True
Undo
End If

Pampers [afro]
Just let it go...
 
It woiks Moe. That's for the double team.
I will send another donation to the club.
For readers, i will summarize what i used here successfully.

In the combo fields Before Update line:


Private Sub cboBlendClassID_BeforeUpdate(Cancel As Integer)

Dim Msg As String, Style As Integer
Dim Title As String, DL As String

DL = vbNewLine & vbNewLine

Msg = "You changed the Value; Do you want to change this?" & DL & _
"Click 'Yes' to continue with the change." & DL & _
"Click 'No' to abort the change . . ."
Style = vbInformation + vbYesNo
Title = "User Action Required! . . ."

If MsgBox(Msg, Style, Title) = vbNo Then
Cancel = True
Undo
End If

End Sub


Knucklehead
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top