I created my first VBA application and I added error checking for severval text boxes (.txtOrganization, txtStartYear, txtStartMonth, txtEndYear, txtEndMonth) as you can notice the error checking happens in several user define functions and thus if a person does not fill in a text box in several areas. Each function will create a msgbox which can lead to several msgboxes on the screen. How can I streamline this process that only one msgbox appears on the screen stating all the boxes that need to be filled in??? also since this is my first VBA app any ideas how to make this a better app?? Thanks in advance





Private Sub cmdInsert_Click()

    Info
    StartDate
    EndDate
    FTE
    RelevanceScale
End Sub


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