VB Yes/No Code

Leesha
BronzeLounger
Posts: 1357
Joined: 05 Feb 2010, 22:25

VB Yes/No Code

Post by Leesha »

Hi,

I have a form with a list on it. When the user double clicks the list it updates a text box on the form. I need to be sure that the user has the option to stop the update if they double clicked the list by accident. The part that isn't working is the code where the msgbox should come up and give the user the choice of changing the data or not.

Thanks!
Leesha

Code: Select all

Private Sub lstPossibleEmotionalCause_DblClick(Cancel As Integer)

'Checks to see if there is an emotional dx in the corresponding box and asks if it should ne replaced.

If IsNull(Me.ClientChosenEmotionalProblemLink) Then
    Me.txtClientIdentifiedEmotionalCause = txtEmotionalCauseID
    ElseIf Not IsNull(Me.ClientChosenEmotionalProblemLink) Then

    If MsgBox("There is already data in the Client Identified Emotional Cause box.  Do you wish to replace it", vbYesNo) = vbYes Then
     'enter code that should run if the answer is yes
       Me.txtClientIdentifiedEmotionalCause = txtEmotionalCauseID
   
      Else:

     'Do Nothing
    
     End If
     End If

User avatar
HansV
Administrator
Posts: 74155
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: VB Yes/No Code

Post by HansV »

What are:
ClientChosenEmotionalProblemLink
txtClientIdentifiedEmotionalCause
txtEmotionalCauseID
Regards,
Hans

Leesha
BronzeLounger
Posts: 1357
Joined: 05 Feb 2010, 22:25

Re: VB Yes/No Code

Post by Leesha »

Hi Hans! I was just writing back to say I found the issue and it's running OK. I had referenced the wrong control.
Thanks!
Leesha

User avatar
HansV
Administrator
Posts: 74155
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: VB Yes/No Code

Post by HansV »

Thanks for the feedback.
Regards,
Hans