[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Loop and build Message for USer in Access 2003

Posted on 2012-09-19
2
Medium Priority
?
584 Views
Last Modified: 2012-09-19
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
Comment
Question by:ssmith94015
2 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 2000 total points
ID: 38415675
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
 

Author Closing Comment

by:ssmith94015
ID: 38415765
That was it.  I was initizlaing th variable strMessage in the wrong place.  Thank you.

Sandra
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft's Excel has many features that most people will never need nor take advantage of.  Conditional formatting is one feature that you may find a necessity once you start using it.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question