vbYesNo response to populate another field

  • Thread starter Thread starter Devon
  • Start date Start date
D

Devon

Good morning

I am attempting to use vbYesNo within an If/Then statement to populate a
separate field. Essentially, one of the fields on a Main form will be either
Unlimited, or have some sort of limit. If there is a limit, I am trying to
have on BeforeUpdate in a subform to give a pop-up vbYesNo box to give the
user a warning that the field from the Main Form has a limt, and to have them
acknowledge reading this warning. I would like it to be if the user chooses
Yes, then a field on the subform named Acknowledgement becomes Yes, if they
choose No, then they will not be able to proceed any further.

Below is what I have created thus far. I have found similar examples within
this forum, but not that use the Boolean logic I need. I get the vbYesNo box
with all the correct dialogue, however, regardless of choosing Yes or No, the
Acknowledgement box turns to Yes.

Help would be appreciated.

Thanks

If ([Forms]![Main_Form].[Field1]) <> "Unlimited" Then
MsgBox "Warning to the user Dialogue...", vbYesNo
If vbYes Then
Me.Acknowledgement = "Yes"
Else
Me.Acknowledgement = "No"
MsgBox "You are not allowed to proceed."

End If
End If
 
Jim

Worked perfectly!! Thank you very much.

Devon

JimBurke via AccessMonster.com said:
You need to use the form of MsgBox that returns a value. I like to use a
variable to get the msgbox return value for readability purposes - a lot of
people just code it right in the If-the-Else. Here's how I would do it:

If ([Forms]![Main_Form].[Field1]) <> "Unlimited" Then
answer =MsgBox("Warning to the user Dialogue...", vbYesNo)
If answer = vbYes Then
Me.Acknowledgement = "Yes"
Else....

You can also code it as

If MsgBox("Warning to the user Dialogue...", vbYesNo) = vbYes Then...

You should Dim the 'answer' variable if you use my way - I think it's an
Integer value.

Good morning

I am attempting to use vbYesNo within an If/Then statement to populate a
separate field. Essentially, one of the fields on a Main form will be either
Unlimited, or have some sort of limit. If there is a limit, I am trying to
have on BeforeUpdate in a subform to give a pop-up vbYesNo box to give the
user a warning that the field from the Main Form has a limt, and to have them
acknowledge reading this warning. I would like it to be if the user chooses
Yes, then a field on the subform named Acknowledgement becomes Yes, if they
choose No, then they will not be able to proceed any further.

Below is what I have created thus far. I have found similar examples within
this forum, but not that use the Boolean logic I need. I get the vbYesNo box
with all the correct dialogue, however, regardless of choosing Yes or No, the
Acknowledgement box turns to Yes.

Help would be appreciated.

Thanks

If ([Forms]![Main_Form].[Field1]) <> "Unlimited" Then
MsgBox "Warning to the user Dialogue...", vbYesNo
If vbYes Then
Me.Acknowledgement = "Yes"
Else
Me.Acknowledgement = "No"
MsgBox "You are not allowed to proceed."

End If
End If
 
Back
Top