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!

Required text Macro at completion of form. 1

Status
Not open for further replies.
Aug 4, 2004
84
0
0
US
I have a form that should be fully completed by an employee. At the end of the form the final step is selecting, by combo box, whether an assignment is confirmed or not. I am wondering if it is possible, when an employee selects "yes" in the confirmed combo box, to have a macro that will check to see if all text boxes are filled in. If not, the form will not close unless fully completed.

Thanks for the help,

ab
 
something like

Private Sub Combo6_AfterUpdate()

If Combo6.Text = "Yes" Then
If Text0.Text = "" Then GoTo Please_Complete
If Text0.Text = "" Then GoTo Please_Complete
If Text0.Text = "" Then GoTo Please_Complete


End If

Exit Sub
Please_Complete

MsgBox ("Type message")

End Sub



David Lerwill
"If at first you don't succeed go to the pub"
 
thanks for the reply.

So i would have to call all of the text boxes on the form individually?
like:

If Combo6.Text = "Yes" Then
If Text23.Text = "" Then GoTo Please_Complete
If First.Text = "" Then GoTo Please_Complete
If Last.Text = "" Then GoTo Please_Complete
etc....
 
It depends on the names. you could create an array and use a do until event to save time

David Lerwill
"If at first you don't succeed go to the pub"
 
ok so since I do not know how create an array and am not to familiar with the code for do until, naming all text boxes like above will work, or no?
 
I'm not an expert on arrays will see if I can dig up a sample for your to look at.

David Lerwill
"If at first you don't succeed go to the pub"
 
Thanks for all the input and help.

I have tried the code you mentioned above with one text box and it is giving me an error in VB saying that it does not recognize the following:

Private Sub confirmed_AfterUpdate()[/color yellow]

If Confirmed.Text = "Yes" Then
If Offlimits.Text = "" Then GoTo Please_Complete


End If

Exit Sub
Please_Complete

MsgBox ("Type message")
End Sub
 
oops try

Private Sub confirmed_AfterUpdate()

If Confirmed.Text = "Yes" Then

Offlimits.SetFocus
If Offlimits.Text = "" Then GoTo Please_Complete


End If

Exit Sub
Please_Complete:

MsgBox ("Type message")
End Sub

David Lerwill
"If at first you don't succeed go to the pub"
 
nice one, worked!

ok last thing, would i repeat code for text boxes i require being filled in:

Private Sub confirmed_AfterUpdate()

If Confirmed.Text = "Yes" Then

Offlimits.SetFocus
If Offlimits.Text = "" Then GoTo Please_Complete

fee.SetFocus
If fee.Text = "" Then GoTo Please_Complete

End If

Exit Sub
Please_Complete:

MsgBox ("Type message")
End Sub
David Lerwill


 
Yup thats it.

David Lerwill
"If at first you don't succeed go to the pub"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top