Loop and build Message for USer in Access 2003

Users in our database have only calendar days in which to entered data.  I need to have a process that loops through the table and for each day four to seven days past today, create a message that informs the user which days are missing.  I want to build one message but am not sure how to join the loops

Sandra

Private Sub CheckforDataEntry(strUserID As String)
'Checks to see if the user has inputted data for days older than four from today
Dim intCount As Integer
Dim strMessage As String
Dim i As Integer

For i = 4 To 7
intCount = DCount("TaskDate", "tblCompletedTask", "UserID = '" & gstrUserID & "' AND TaskDate = Date() - " & i)

    If intCount = 0 Then
        'Do nothing
    Else
        strMessage = "You have no entries for the date: " & Date - i & " & vbCrLf"
       
    End If
   
Next i


End Sub
Sandra SmithRetiredAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mbizupCommented:
Try this:


Private Sub CheckforDataEntry(strUserID As String)
'Checks to see if the user has inputted data for days older than four from today
Dim intCount As Integer
Dim strMessage As String
Dim i As Integer


 strMessage = "You have no entries for the following dates: " & vbcrlf
For i = 4 To 7
intCount = DCount("TaskDate", "tblCompletedTask", "UserID = '" & gstrUserID & "' AND TaskDate = Date() - " & i)

    If intCount = 0 Then
        'Do nothing
    Else
        strMessage = strMessage & ( Date - i ) & vbCrLf"
        
    End If
    
Next i


End Sub

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Sandra SmithRetiredAuthor Commented:
That was it.  I was initizlaing th variable strMessage in the wrong place.  Thank you.

Sandra
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.