ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Userforms (https://www.excelbanter.com/excel-programming/339799-userforms.html)

restrepoblessin

Userforms
 

Hey, I'm a beginner and I just wanted to ask if does anyone know how to
create a code that would make the users of a userform fill out certain
textfields, or show them a message saying that they have to type
information before adding the data to the spreadsheet? I've already
created the code for the userform so I will take forever to create a
code for each one of the txtFields so is there anyway I can create one
that would required that for all of them at once?

Do I make my self clear?


--
restrepoblessin
------------------------------------------------------------------------
restrepoblessin's Profile: http://www.excelforum.com/member.php...o&userid=27170
View this thread: http://www.excelforum.com/showthread...hreadid=466781


Jim Thomlinson[_4_]

Userforms
 
Place the validation in your Ok and Exit procedures. The user has to leave
the form to get cack to the spreadsheet (usually through an OK button or
something similar). In the code for this button do something like this...

sub cmdOK_Click()

if trim(textbox1.value) = "" then
msgbox "Please ensure that all required fields are completed before
proceeding"
textbox1.setfocus
elseif trim(textbox2.value) = "" then
msgbox "Please ensure that all required fields are completed before
proceeding"
textbox2.setfocus
else
me.hide
end if
end sub
--
HTH...

Jim Thomlinson


"restrepoblessin" wrote:


Hey, I'm a beginner and I just wanted to ask if does anyone know how to
create a code that would make the users of a userform fill out certain
textfields, or show them a message saying that they have to type
information before adding the data to the spreadsheet? I've already
created the code for the userform so I will take forever to create a
code for each one of the txtFields so is there anyway I can create one
that would required that for all of them at once?

Do I make my self clear?


--
restrepoblessin
------------------------------------------------------------------------
restrepoblessin's Profile: http://www.excelforum.com/member.php...o&userid=27170
View this thread: http://www.excelforum.com/showthread...hreadid=466781




All times are GMT +1. The time now is 08:23 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com