Checking a userform for blanks

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Does anyone know of a web site, tutorial, or bit of code I can attach to a
button to check its userform for blanks (no entry). I would like form to
check to see if there are any missing answers and if every question has been
answered, then it posts the values to the spreadsheet.

I've tried a few things , and made a lot of searches, but all for naught.

Thanks,

WillRn
 
For Each ctl In Me.Controls
If TypeName(ctl) = "TextBox" Then
If ctl.Text = "" Then
Msgbox "Missing answer"
Exit For
End If
End If
Next ctl

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
This worked for checking the form, but I would really like the code to take
the user to the missing answer and ask them to fill it in. Is this possible?
 
For Each ctl In Me.Controls
If TypeName(ctl) = "TextBox" Then
If ctl.Text = "" Then
Msgbox "Missing answer, please complete"
ctl.Select
Exit For
End If
End If
Next ctl


--

HTH

RP
(remove nothere from the email address if mailing direct)
 
So far so good, but I keep getting: "Run-Time error '450' wrong number of
arguments or invalid property assignment.
 
Wrong syntax

Dim ctl

For Each ctl In Me.Controls
If TypeName(ctl) = "TextBox" Then
If ctl.Text = "" Then
MsgBox "Missing answer, please reset"
ctl.SetFocus
Exit For
End If
End If
Next ctl

--

HTH

RP
(remove nothere from the email address if mailing direct)
 

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

Back
Top