Msbbox - VBok for empty text boxes

A

Anauna

Hello,

Created a template with a user form to collect information. Form text and
combo boxes drop information into bookmarks. Everything here works fine.

I have had no success in completing code to get a general message box to
display if any of the text or combo boxes have been left blank when the user
clicks the submit button.
I would like the user to receive the msg. and click OK to return to the from
I am placing my attempt in the cmdSubmit_Click()

Still new to VBA...
 
D

Doug Robbins

Use

If Trim([ControlName])="" Then
MsgBox "Please enter the required information into [ControlName]."
[ControlName].SetFocus
End If

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
A

Anauna

Hi Doug,

Thank you for responding.

When I enter the code below in the my CmdSumbit click event the msgbox
appears fine but instead of the focus returning to the textbox the form
unloads...

I have placed the code after the .Bookmarks...=....Text code and just
before 'Unload Me'

Sorry if I am making this more complicated than it should be.

Doug Robbins said:
Use

If Trim([ControlName])="" Then
MsgBox "Please enter the required information into [ControlName]."
[ControlName].SetFocus
End If

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
Anauna said:
Hello,

Created a template with a user form to collect information. Form text and
combo boxes drop information into bookmarks. Everything here works fine.

I have had no success in completing code to get a general message box to
display if any of the text or combo boxes have been left blank when the
user
clicks the submit button.
I would like the user to receive the msg. and click OK to return to the
from
I am placing my attempt in the cmdSubmit_Click()

Still new to VBA...
 
D

Doug Robbins

Include an Exit Sub before the End If

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
Anauna said:
Hi Doug,

Thank you for responding.

When I enter the code below in the my CmdSumbit click event the msgbox
appears fine but instead of the focus returning to the textbox the form
unloads...

I have placed the code after the .Bookmarks...=....Text code and just
before 'Unload Me'

Sorry if I am making this more complicated than it should be.

Doug Robbins said:
Use

If Trim([ControlName])="" Then
MsgBox "Please enter the required information into [ControlName]."
[ControlName].SetFocus
End If

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
Anauna said:
Hello,

Created a template with a user form to collect information. Form text
and
combo boxes drop information into bookmarks. Everything here works
fine.

I have had no success in completing code to get a general message box
to
display if any of the text or combo boxes have been left blank when the
user
clicks the submit button.
I would like the user to receive the msg. and click OK to return to the
from
I am placing my attempt in the cmdSubmit_Click()

Still new to VBA...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top