Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default error checking Streamlined


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
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
Error checking jason2444 Excel Discussion (Misc queries) 3 August 28th 07 09:29 PM
Error Checking SammyB Excel Discussion (Misc queries) 2 June 4th 07 10:48 AM
Error Checking Lost in Microbiology Excel Discussion (Misc queries) 8 May 11th 07 05:36 AM
Error Checking mworth01 Excel Discussion (Misc queries) 1 May 18th 06 08:45 PM
OptionBox error checking Patrick Simonds Excel Programming 1 September 29th 05 08:39 AM


All times are GMT +1. The time now is 06:09 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"