Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() I created my first VBA application and I added error checking fo severval text boxes (.txtOrganization, txtStartYear, txtStartMonth txtEndYear, txtEndMonth) as you can notice the error checking happen in several user define functions and thus if a person does not fill i a text box in several areas. Each function will create a msgbox whic can lead to several msgboxes on the screen. How can I streamline thi process that only one msgbox appears on the screen stating all th boxes that need to be filled in??? also since this is my first VBA ap any ideas how to make this a better app?? Thanks in advance Code ------------------- Private Sub cmdInsert_Click() Info StartDate EndDate FTE RelevanceScale End Sub ------------------- Code ------------------- Dim CellPosition As Range Dim counter As Integer Function Info() counter = 1 Set CellPosition = Range("a13") Do While counter <= 10 If CellPosition.Value = "" Then If frmWorkHistory.txtOrganization.Value = "" Then MsgBox "Organization Name Field Required" Exit Do Else CellPosition.Value = frmWorkHistory.txtOrganization.Value & " " & frmWorkHistory.txtPosition.Value Exit Do End If Else Set CellPosition = CellPosition.Offset(1, 0) counter = counter + 1 End If Loop End Function Function StartDate() counter = 1 Set CellPosition = Range("C13") Do While counter <= 10 If CellPosition.Value = "" Then If frmWorkHistory.txtStartYear.Value = "" Or frmWorkHistory.txtStartMonth.Value = "" Then MsgBox = "Start Date Field Required" Exit Do Else CellPosition.Value = DateSerial(frmWorkHistory.txtStartYear.Value, frmWorkHistory.txtStartMonth.Value, 1) Exit Do End If Else Set CellPosition = CellPosition.Offset(1, 0) counter = counter + 1 End If Loop End Function Function EndDate() counter = 1 Set CellPosition = Range("D13") Do While counter <= 10 If CellPosition.Value = "" Then If frmWorkHistory.txtEndYear.Value = "" Or frmWorkHistory.txtEndMonth.Value = "" Then MsgBox = "End Date Field Required" Exit Do Else CellPosition.Value = DateSerial(frmWorkHistory.txtEndYear.Value, frmWorkHistory.txtEndMonth.Value, 1) Exit Do End If Else Set CellPosition = CellPosition.Offset(1, 0) counter = counter + 1 End If Loop End Function Function FTE() counter = 1 Set CellPosition = Range("F13") Do While counter <= 10 If CellPosition.Value = "" Then CellPosition.Value = frmWorkHistory.cboFTE.Value Exit Do Else Set CellPosition = CellPosition.Offset(1, 0) counter = counter + 1 End If Loop End Function Function RelevanceScale() counter = 1 Set CellPosition = Range("G13") Do While counter <= 10 If CellPosition.Value = "" Then CellPosition.Value = frmWorkHistory.cboRelevanceScale.Value Exit Do Else Set CellPosition = CellPosition.Offset(1, 0) counter = counter + 1 End If Loop End Function ------------------- -- cedtech2 ----------------------------------------------------------------------- cedtech23's Profile: http://www.excelforum.com/member.php...fo&userid=3102 View this thread: http://www.excelforum.com/showthread.php?threadid=50819 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Error checking | Excel Discussion (Misc queries) | |||
Error Checking | Excel Discussion (Misc queries) | |||
Error Checking | Excel Discussion (Misc queries) | |||
Error Checking | Excel Discussion (Misc queries) | |||
OptionBox error checking | Excel Programming |