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

Yes / No Msgbox

Status
Not open for further replies.

vols77

Technical User
Feb 17, 2007
29
US
I really could use some help.
I need a yes/no msgbox to appear if the field "BOL" is either blank or they have entered then erased the value.

Yes/no because if they go to the next record or exit the form, the record will not be savedf.

It has been an extremely long time and I will admit my memory has slipped and any help is greatly appreciated!
 
How about something like (Text2 in this example is the textbox containing the BOL value):
Code:
If Len(Me!Text2 & "") < 1 Then
    Select Case MsgBox("Your message", vbExclamation + vbYesNo, "Your caption")
        Case vbYes
            'code for yes
        Case vbNo
            'code for no
    End Select
End If
Hope this helps

HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Thank you!
Think I am almost there but have one slight problem...

If Len(Me.BOL & vbNullString) = 0 Then
Select Case MsgBox("Do you want to exit? If so, your record will not be saved.", vbExclamation + vbYesNo, "No BOL # - Record can not be saved")
Case vbYes
Cancel = True
Case vbNo
Me.BOL.SetFocus
End Select
End If


This works if I click NO, but I guess cancel=true does not wipe out the current record... does anyone have ideas as to how have "Yes" clear the current record?
 

Just to be clear here, if BOL is empty, you want a messagebox to popup and warn the user and offer a chance to either fill in the missing data or dump the record?

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.BOL = "" Or IsNull(Me.BOL) Then
If MsgBox("To save this record you need to enter a value in the BOL field! Would you like to save this record?", vbQuestion + vbYesNo + vbDefaultButton1, "Save This Record ???") = vbNo Then
Me.Undo
Else
Cancel = True
BOL.SetFocus
End If
End If
End Sub


The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Thank you to all! The code is working and in multiple areas!

Not easy getting back in the grove when I have not written any code in over 2 years.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top