If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Adding a MsgBox when criteria are true
I have a a form that contains 2 text boxes that are not used every time the
form is used. However, if the first box is used the second must be used. So do I create a MsgBox to pop up based on an if then equation(?)? The end result would be that when the user exits the second text box (OnExit) it would look at the previous box and determine if the default value ($0.00) was changed (always a 0 amount). If yes, and the exited text box is still empty, then put up a pop up to remind that it must be filled in. Does that makes sense or is there an easier way? -- Thanks and God bless you and yours, Gabriella777_2 |
#2
|
|||
|
|||
Adding a MsgBox when criteria are true
Since it's possible that they might not actually tab through the second
textbox, I'd recommend putting the logic in the form's BeforeUpdate Event: Private Sub Form_BeforeUpdate(Cancel As Integer) If Me.Textbox1 0 And IsNull(Me.Textbox2) = True Then MsgBox "You must provide a value for both Textbox1 and Textbox2" Cancel = True End If End Sub -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Gabriella777_2" wrote in message ... I have a a form that contains 2 text boxes that are not used every time the form is used. However, if the first box is used the second must be used. So do I create a MsgBox to pop up based on an if then equation(?)? The end result would be that when the user exits the second text box (OnExit) it would look at the previous box and determine if the default value ($0.00) was changed (always a 0 amount). If yes, and the exited text box is still empty, then put up a pop up to remind that it must be filled in. Does that makes sense or is there an easier way? -- Thanks and God bless you and yours, Gabriella777_2 |
#3
|
|||
|
|||
Adding a MsgBox when criteria are true
Okay, I did as you suggested and it worked accept . . .
1. I got a pop up saying I can't go to the specified record after clicking on the command button I created to go to the next record. 2. When I clicked the Close Form command button, I got the msgbox but after clicking okay it closed the form anyway. I added a SetFocus line to what you had me put in, with it setting Textbox 2 as the focus. That worked on the next record button but not on the close form button. -- Thanks and God bless you and yours, Gabriella777_2 "Douglas J. Steele" wrote: Since it's possible that they might not actually tab through the second textbox, I'd recommend putting the logic in the form's BeforeUpdate Event: Private Sub Form_BeforeUpdate(Cancel As Integer) If Me.Textbox1 0 And IsNull(Me.Textbox2) = True Then MsgBox "You must provide a value for both Textbox1 and Textbox2" Cancel = True End If End Sub -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Gabriella777_2" wrote in message ... I have a a form that contains 2 text boxes that are not used every time the form is used. However, if the first box is used the second must be used. So do I create a MsgBox to pop up based on an if then equation(?)? The end result would be that when the user exits the second text box (OnExit) it would look at the previous box and determine if the default value ($0.00) was changed (always a 0 amount). If yes, and the exited text box is still empty, then put up a pop up to remind that it must be filled in. Does that makes sense or is there an easier way? -- Thanks and God bless you and yours, Gabriella777_2 |
#4
|
|||
|
|||
Adding a MsgBox when criteria are true
Okay I put the code in the text box 2 OnExit rather than the form and it
worked perfectly. Just what I wanted it to do! Thanks for the help! -- Thanks and God bless you and yours, Gabriella777_2 "Douglas J. Steele" wrote: Since it's possible that they might not actually tab through the second textbox, I'd recommend putting the logic in the form's BeforeUpdate Event: Private Sub Form_BeforeUpdate(Cancel As Integer) If Me.Textbox1 0 And IsNull(Me.Textbox2) = True Then MsgBox "You must provide a value for both Textbox1 and Textbox2" Cancel = True End If End Sub -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Gabriella777_2" wrote in message ... I have a a form that contains 2 text boxes that are not used every time the form is used. However, if the first box is used the second must be used. So do I create a MsgBox to pop up based on an if then equation(?)? The end result would be that when the user exits the second text box (OnExit) it would look at the previous box and determine if the default value ($0.00) was changed (always a 0 amount). If yes, and the exited text box is still empty, then put up a pop up to remind that it must be filled in. Does that makes sense or is there an easier way? -- Thanks and God bless you and yours, Gabriella777_2 |
#5
|
|||
|
|||
Adding a MsgBox when criteria are true
You must correct the error before you can proceed. If you decide you don't
want to save the erroneous record, hit the Esc key (you might have to hit it twice). It just occurred to me that the following would be safer: If Nz(Me.Textbox1, 0) 0 And IsNull(Me.Textbox2) = True Then -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Gabriella777_2" wrote in message ... Okay, I did as you suggested and it worked accept . . . 1. I got a pop up saying I can't go to the specified record after clicking on the command button I created to go to the next record. 2. When I clicked the Close Form command button, I got the msgbox but after clicking okay it closed the form anyway. I added a SetFocus line to what you had me put in, with it setting Textbox 2 as the focus. That worked on the next record button but not on the close form button. -- Thanks and God bless you and yours, Gabriella777_2 "Douglas J. Steele" wrote: Since it's possible that they might not actually tab through the second textbox, I'd recommend putting the logic in the form's BeforeUpdate Event: Private Sub Form_BeforeUpdate(Cancel As Integer) If Me.Textbox1 0 And IsNull(Me.Textbox2) = True Then MsgBox "You must provide a value for both Textbox1 and Textbox2" Cancel = True End If End Sub -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Gabriella777_2" wrote in message ... I have a a form that contains 2 text boxes that are not used every time the form is used. However, if the first box is used the second must be used. So do I create a MsgBox to pop up based on an if then equation(?)? The end result would be that when the user exits the second text box (OnExit) it would look at the previous box and determine if the default value ($0.00) was changed (always a 0 amount). If yes, and the exited text box is still empty, then put up a pop up to remind that it must be filled in. Does that makes sense or is there an easier way? -- Thanks and God bless you and yours, Gabriella777_2 |
Thread Tools | |
Display Modes | |
|
|