Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default Forms - checking fileds have values

Hi All,

I have a form with approx 20 fields made up of comboboxes & textboxes. I
have renamed them so that the code is easier to read. ie they are no longer
ComboBox1, ComboBox2 etc.

Does anybody have any code which will check that none of the fields are
blank ?

I can write the code to check each field individually but it seems to me to
be a very inelegant solution.

Also,

Is it possible to restrict entries (ie only Alpha chararcters allowed or
only numerical characters allowed) and the number of characters ?

All help gratefully appreciated

Regards

Michael Beckinsale


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Forms - checking fileds have values

for each ctrl in Userform1.Controls
if typeof ctrl is MSForms.TextBox then
if ctrl.Value < "" then

end if
if typeof ctrl is MSForms.ComboBox then
if ctrl.Value < "" then

end if
end if
Next

Assuming you mean textboxes (comboboxes can be restricted to the items in
the list)

This example at John Walkenbach's site shows how to handle multiple controls
in a class module:

http://www.j-walk.com/ss/excel/tips/tip44.htm
Handle Multiple UserForm Buttons With One Subroutine

you would put code in there to do the validation. Even though the above
code is for commandbuttons, it can be used with other msforms controls as
well.

--
Regards,
Tom Ogilvy



"Michael Beckinsale" wrote in message
...
Hi All,

I have a form with approx 20 fields made up of comboboxes & textboxes. I
have renamed them so that the code is easier to read. ie they are no

longer
ComboBox1, ComboBox2 etc.

Does anybody have any code which will check that none of the fields are
blank ?

I can write the code to check each field individually but it seems to me

to
be a very inelegant solution.

Also,

Is it possible to restrict entries (ie only Alpha chararcters allowed or
only numerical characters allowed) and the number of characters ?

All help gratefully appreciated

Regards

Michael Beckinsale




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default Forms - checking fileds have values

Tom,

Thats great. Exactly what l need. Thank you very much.

Regards

Michael.

"Tom Ogilvy" wrote in message
...
for each ctrl in Userform1.Controls
if typeof ctrl is MSForms.TextBox then
if ctrl.Value < "" then

end if
if typeof ctrl is MSForms.ComboBox then
if ctrl.Value < "" then

end if
end if
Next

Assuming you mean textboxes (comboboxes can be restricted to the items in
the list)

This example at John Walkenbach's site shows how to handle multiple
controls
in a class module:

http://www.j-walk.com/ss/excel/tips/tip44.htm
Handle Multiple UserForm Buttons With One Subroutine

you would put code in there to do the validation. Even though the above
code is for commandbuttons, it can be used with other msforms controls as
well.

--
Regards,
Tom Ogilvy



"Michael Beckinsale" wrote in message
...
Hi All,

I have a form with approx 20 fields made up of comboboxes & textboxes. I
have renamed them so that the code is easier to read. ie they are no

longer
ComboBox1, ComboBox2 etc.

Does anybody have any code which will check that none of the fields are
blank ?

I can write the code to check each field individually but it seems to me

to
be a very inelegant solution.

Also,

Is it possible to restrict entries (ie only Alpha chararcters allowed or
only numerical characters allowed) and the number of characters ?

All help gratefully appreciated

Regards

Michael Beckinsale






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Checking values in 2 columns BRob Excel Worksheet Functions 4 May 1st 08 02:32 PM
Checking a column of values against another one BRob Charts and Charting in Excel 1 May 1st 08 09:18 AM
Checking on two values Johannes B. Excel Discussion (Misc queries) 4 April 22nd 05 06:49 PM
checking for missing values Jerry[_17_] Excel Programming 4 February 16th 04 09:34 PM
checking values in a cel solo_razor[_8_] Excel Programming 2 September 18th 03 01:37 PM


All times are GMT +1. The time now is 05:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"