• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 604
  • Last Modified:

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
0
Sandra Smith
Asked:
Sandra Smith
1 Solution
 
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

0
 
Sandra SmithRetiredAuthor Commented:
That was it.  I was initizlaing th variable strMessage in the wrong place.  Thank you.

Sandra
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now