Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default message box to check value

How would I get a message box to check if a combobox has something in it,
after a command button is selected?

Example. I have a user form(entry) that draws data from a database
spreadsheet, it populates several textboxes, togglebuttons, and a couple
combo boxes. One of the comboboxes that doesn't get updated is ethnicity,
which the user has to select an ethnicity, of which there are several. At the
bottom of the userform is a command button that will put all of the data that
is in the user form, and place it in a form spreadsheet underneath it.

End state. What I would like to happen is that when the user clicks on the
command button "add data to underlying form", a message box pops up and tells
the user that "you forgot to select an ethnicity", and then stop the macro
associated with the commandbutton "add data to underlying form", if the user
forgot to select an ethnicity from the combobox.

Please help!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default message box to check value

In your command_click module:
' Assumes combobox1 is "Ethnicity" combo ....
If combobox1.listindex=-1 then <== change combobox1 to suit
Msgbox "Please select ethnicity"
exit sub
end if


HTH
"BigPig" wrote:

How would I get a message box to check if a combobox has something in it,
after a command button is selected?

Example. I have a user form(entry) that draws data from a database
spreadsheet, it populates several textboxes, togglebuttons, and a couple
combo boxes. One of the comboboxes that doesn't get updated is ethnicity,
which the user has to select an ethnicity, of which there are several. At the
bottom of the userform is a command button that will put all of the data that
is in the user form, and place it in a form spreadsheet underneath it.

End state. What I would like to happen is that when the user clicks on the
command button "add data to underlying form", a message box pops up and tells
the user that "you forgot to select an ethnicity", and then stop the macro
associated with the commandbutton "add data to underlying form", if the user
forgot to select an ethnicity from the combobox.

Please help!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default message box to check value

Toppers,

Thankyou very much! It worked perfectly.

Now I have another question.

How would I get a message box to check through all of the text boxes, combo
boxes, etc to ensure that something was entered? And then display within the
message box what textboxes/comboboxes were left blank?

Thanks again for your help!

"Toppers" wrote:

In your command_click module:
' Assumes combobox1 is "Ethnicity" combo ....
If combobox1.listindex=-1 then <== change combobox1 to suit
Msgbox "Please select ethnicity"
exit sub
end if


HTH
"BigPig" wrote:

How would I get a message box to check if a combobox has something in it,
after a command button is selected?

Example. I have a user form(entry) that draws data from a database
spreadsheet, it populates several textboxes, togglebuttons, and a couple
combo boxes. One of the comboboxes that doesn't get updated is ethnicity,
which the user has to select an ethnicity, of which there are several. At the
bottom of the userform is a command button that will put all of the data that
is in the user form, and place it in a form spreadsheet underneath it.

End state. What I would like to happen is that when the user clicks on the
command button "add data to underlying form", a message box pops up and tells
the user that "you forgot to select an ethnicity", and then stop the macro
associated with the commandbutton "add data to underlying form", if the user
forgot to select an ethnicity from the combobox.

Please help!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default message box to check value

Something like:

As there are only two comboboxes I didn't loop as per textboxes below

Dim errfound as boolean
ErrFound=False

If combobox1.listindex=-1 then <== change combobox1 to suit
Msgbox "Please select ethnicity"
errfound=True
end if
If combobox2.listindex=-1 then <== change combobox2 to suit
Msgbox "Please select ....."
errfound=true
end if

If textboxes are named "textbox1","textbox2" ... then:

' array holding error meesages for textboxes ...
Errmsg=array("Race","Gender" ...........) <=== index for <errmsg array
starts at 0 not 1



For i=1 to ntxtBoxes <=== number of textboxes
If controls("textbox" & i).value="" then
msgbox "Please enter a value for " & errmsg(i-1)
errfound=True
end if
Next i
' an error has been found so exit
If errfound then exit sub

....... Everything is OK so add data ....

HTH

"BigPig" wrote:

Toppers,

Thankyou very much! It worked perfectly.

Now I have another question.

How would I get a message box to check through all of the text boxes, combo
boxes, etc to ensure that something was entered? And then display within the
message box what textboxes/comboboxes were left blank?

Thanks again for your help!

"Toppers" wrote:

In your command_click module:
' Assumes combobox1 is "Ethnicity" combo ....
If combobox1.listindex=-1 then <== change combobox1 to suit
Msgbox "Please select ethnicity"
exit sub
end if


HTH
"BigPig" wrote:

How would I get a message box to check if a combobox has something in it,
after a command button is selected?

Example. I have a user form(entry) that draws data from a database
spreadsheet, it populates several textboxes, togglebuttons, and a couple
combo boxes. One of the comboboxes that doesn't get updated is ethnicity,
which the user has to select an ethnicity, of which there are several. At the
bottom of the userform is a command button that will put all of the data that
is in the user form, and place it in a form spreadsheet underneath it.

End state. What I would like to happen is that when the user clicks on the
command button "add data to underlying form", a message box pops up and tells
the user that "you forgot to select an ethnicity", and then stop the macro
associated with the commandbutton "add data to underlying form", if the user
forgot to select an ethnicity from the combobox.

Please help!

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
Increase size of a Forms Check Box (click on to enter check mark) 718Satoshi Excel Discussion (Misc queries) 0 August 17th 07 01:52 AM
I need a pop up message when a check box is checked Kipp Excel Discussion (Misc queries) 1 October 20th 05 11:50 PM
disable spell check pop-up message Greg Excel Programming 3 February 15th 05 04:11 PM
how do I stop pop-up message after spell check elittos Excel Programming 2 February 15th 05 04:06 PM
Displaying a message in a message box without requiring user to click anything to proceed Android[_2_] Excel Programming 2 June 25th 04 06:44 PM


All times are GMT +1. The time now is 06:14 AM.

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

About Us

"It's about Microsoft Excel"