Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / April 2006

Tip: Looking for answers? Try searching our database.

Looping

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
State Troopers - 27 Apr 2006 16:49 GMT
Hi there.

this is going to be a rather lenthy post. But I will try and explain my
problem as clearly as possible.

Firstly, I have a table(tblActions). In this table, I have several fields.
they are: ID, CATEGORY, COMMENT, CLOSED, and DATE

Secondly, the process: The Form is divided into 5 sections, each one of
these sections represents a CATEGORY number. The user enters comments into
these fields. The ID is also stored from user input(the ID is in this format
- 2006-001). The date is automatticaly saved upon submitting the form. Once
an actions(CATEGORY) is completed, it is closed.

The problem:
The user has 30 days to complete the action(single CATEGORY..there are 5
actions that need completion, but all can be different time points)
On the 30th day after an action has been entered an email is sent
automatically to the user, telling them which CATEGORY needs to be completed,
and from which ID.
The problem here is that when the user enters data it looks like this:

ID              CAT     COMMENT    CLOSE       DATE
2006-001      1       testing....                       4/25/2006
2006-001      1       CLOSED        CLOSED     4/27/2006
2006-001      2       test..1..2                        4/23/2006
2006-001      2       more to do.                    4/25/2006

As you can see, the first time the user enters the information there is no
CLOSED field tagged with it.

I have the email part working, with everything else. The part I am having
trouble with is trying to code in that when it reads that 4/25/2006 is 30
days that it much keep checking for CLOSED. And then if CLOSED doesnt exist,
send the email telling them which ID and CATEGORY needs to be completed.

Heres the working code:

       If strComment = "" Then
   
       Else

           If stDiff30 = 0 Then
           
                   If stDiff48 = 0 Then
                   
                           If stDiff60 = 0 Then
                                       
                               If strDbLine = strLn Then
                               
                                   rsMyRS.MoveNext
                               Else
                               'go
                               message = message & vbNewLine & vbNewLine &
"DIR: " & strDir & vbNewLine & "-Corrective Action Number " & id & " has not
been closed. It has been 30 Days since it was opened."
                               rsMyRS.MoveNext
                               End If
               
                           Else
                       
                           'Debug.Print "60"
                           rsMyRS.MoveNext
                           End If
           
                   
                           If strDbLine = strLn Then
                           
                               rsMyRS.MoveNext
                               
                           Else
                           'go
                           message = message & vbNewLine & vbNewLine &
"DIR: " & strDir & vbNewLine & "-Corrective Action Number " & id & " has not
been closed. It has been 30 Days since it was opened."
                           rsMyRS.MoveNext
                           End If
                   
               
                   Else
               
                   'Debug.Print "48"
                   rsMyRS.MoveNext
                   End If
               
               If strDbLine = strLn Then 'if CLOSED, move on

                   rsMyRS.MoveNext
                   
               Else
               'go        
               rsMyRS.MoveNext                  
               End If            
           Else        
           'Debug.Print "-->30"
           rsMyRS.MoveNext            
           End If
       
       End If

And this is me just think aloud, trying to find a way around this:

strClosed(0)    = 001
strCA(0)    = 1

message30(001)= C.A 1 still open
message48(001)= C.A 2 still open
message60(001)= C.A 3 still open

---------------------------------

strNewDir = Right(strDir, 3)

for x=lbound(strClosed) to ubound(rsMyRS.recordCount) step 1

        if strBoolean(2006-001) = strCA(x) then 'if boolean = strCA
       
               

        else

        message30(001) = vbNewLine & vbNewLine & "DIR: " & strDir & "   (Opened by
" & strUser & ")" & vbNewLine & "-Corrective Action " & id & " has not been
closed. It has been 30 days since it was opened."

        end if

next x

finally, what i need: say the first record it checks is not CLOSED, it
should keep checking the same ID AND CATEGORY fields, looking for CLOSED.
If no CLOSED field is found, then add the EMAIL message to a string, which
is then sent when it has checked EVERY record.

So instead of emailing after every ID check and sending 10 emails(if 10
CATEGORIES have yet to be completed) it will send 1 email - with 10
instructions as to which ID/CATEGORY needs to be completed.

I know it's long. But I tried to explain everything as simple as possible.

Thanks.
-State
State Troopers - 27 Apr 2006 18:16 GMT
I have a possibility that would fix all this madness.

Is it possible to "append" a row, possibly like this:

> ID              CAT     COMMENT    CLOSE       DATE
> 2006-001      1       testing....                       4/25/2006
> 2006-001      1       CLOSED        CLOSED     4/27/2006
> 2006-001      2       test..1..2                        4/23/2006
> 2006-001      2       more to do.                    4/25/2006

......becomes, after some code....

> ID              CAT     COMMENT    CLOSE       DATE
> 2006-001      1       testing....      CLOSED     4/25/2006
> 2006-001      1       CLOSED        CLOSED     4/27/2006
> 2006-001      2       test..1..2                        4/23/2006
> 2006-001      2       more to do.                    4/25/2006

...that would make everything VERY easy.
Better stated, is it possible to add "CLOSED" in the CLOSE field for every
ID, CATEGORY specified?

Thanks again.
-State

> Hi there.
>
[quoted text clipped - 138 lines]
> Thanks.
> -State
State Troopers - 27 Apr 2006 18:22 GMT
Forgot to state, can this be done using a SQL procedure?

> I have a possibility that would fix all this madness.
>
[quoted text clipped - 163 lines]
> > Thanks.
> > -State
State Troopers - 27 Apr 2006 18:26 GMT
Got it.

No need for all that mumbo jumbo coding.

Cheers
-State

> Forgot to state, can this be done using a SQL procedure?
>
[quoted text clipped - 165 lines]
> > > Thanks.
> > > -State
Marshall Barton - 27 Apr 2006 18:40 GMT
Good work State.

I was trying to figure out what the problem was, but you
were posting updates faster than I could get a grip on the
issue  ;-)
Signature

Marsh
MVP [MS Access]

>Got it.
>
[quoted text clipped - 172 lines]
>> > > Thanks.
>> > > -State
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.