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 / General 2 / June 2007

Tip: Looking for answers? Try searching our database.

FillCDays()

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gina Whipp - 20 Jun 2007 20:44 GMT
Hey Guys (and Gals),

What I would like is if an Associate has more than one activity on any
single day it should show them all.  (This end result shows in a calendar
style report.)  Right ow it only shows the first activity.  I have marked
what I think is the offending line (<--THIS LINE), any ideas without me
rewriting the whole thing?

Function FillCdays()
On Error Resume Next
Dim irow As Integer
Dim icol As Integer
        Dim tuseday As String
        Dim tcheckday As String
Dim ans As String
Dim db As DAO.Database
Dim qd As QueryDef
Set db = CurrentDb()
Dim rs As DAO.Recordset
Set qd = db.QueryDefs("qryFillCDays")
qd!FindMonth = Format([scrCDate], "m")
qd!FindYear = Me.txtYear
Set rs = qd.OpenRecordset()
Dim Done As Integer
Done = 0
If rs.EOF And rs.BOF Then
  Else
  Do Until rs.EOF
  If Trim(rs!NameActivity & "") = "" Then
    Else
    ans = ""
    For irow = 0 To 6
      For icol = 0 To 9
        tuseday = rs!Day
        tcheckday = Trim(Left(Me("lbl" & irow & icol), 2))
        If tcheckday = tuseday Then
                Me("lbl" & irow & icol) = Me("lbl" & irow & icol) & vbCrLf
& rs!NameActivity  <--- THIS LINE
                Me("lbl" & irow & icol).FontWeight = 500
        End If
        If Done = 1 Then Exit For
      Next icol
       If Done = 1 Then Exit For
     Next irow
   End If

   rs.MoveNext
   Done = 0
 Loop
End If
rs.Close
End Function

Signature

Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II

Dirk Goldgar - 20 Jun 2007 20:57 GMT
> Hey Guys (and Gals),
>
[quoted text clipped - 48 lines]
> rs.Close
> End Function

Looks like it ought to work, so long as the controls with names like
"lbl##" are text boxes, not labels.  Have you stepped through the code
to verify that the suspect line is actually being executed more than
once for the same day?

Signature

Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

Gina Whipp - 20 Jun 2007 23:56 GMT
Dirk,

I have looked at the underliing query which shows 5 lines on several days
but I am only getting the first line.  And yes they are text boxes.

Signature

Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II

>> Hey Guys (and Gals),
>>
[quoted text clipped - 53 lines]
> verify that the suspect line is actually being executed more than once for
> the same day?
Dirk Goldgar - 21 Jun 2007 04:20 GMT
> Dirk,
>
> I have looked at the underliing query which shows 5 lines on several
> days but I am only getting the first line.

That's not the same as stepping through the code and seeing exactly what
happens.  I suggest you set a breakpoint at the top of the routine
before doing whatever you do that causes the function to be called.
Then step through it line by line, when you know it's working on a day
that should have several lines.

Signature

Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

Gina Whipp - 21 Jun 2007 13:58 GMT
You have a point... off to stepping I go....

Signature

Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II

>> Dirk,
>>
[quoted text clipped - 6 lines]
> through it line by line, when you know it's working on a day that should
> have several lines.
Gina Whipp - 21 Jun 2007 14:06 GMT
Dirk,

Feeling stupid here....  but I can't step into the code behind a form, am I
doing something wrong?

Signature

Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II

>> Dirk,
>>
[quoted text clipped - 6 lines]
> through it line by line, when you know it's working on a day that should
> have several lines.
Dirk Goldgar - 21 Jun 2007 15:07 GMT
> Dirk,
>
> Feeling stupid here....  but I can't step into the code behind a
> form, am I doing something wrong?

You can't directly step into the code behind a form.  What you have to
do is set a breakpoint in the code, and then do whatever user action
will cause the code to be called.  That action might be clicking on a
button, opening or closing the form, navigating to a new record, any
number of things.  Presumably you know what circumstances cause that
function to be called, and can make it happen.  Once you've done that,
the code will begin executing naturally, and will stop at the
breakpoint.  From that point you can single-step through the code in the
usual way.

Signature

Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

Gina Whipp - 21 Jun 2007 16:02 GMT
Dirk,

First, I keep saying form when in fact it is a report...  Regardless, the
code worked for the 11th, 18th and 25th but nothing showed for the 4th?
Okay so it's not the offending line I thought it was.  What I see know is
all my single digit days are showing me nothing.

Query shows days as "04"...

Just to keep all the code together...

Function FillCdays()
On Error Resume Next
Dim irow As Integer
Dim icol As Integer
        Dim tuseday As String
        Dim tcheckday As String
Dim ans As String
Dim db As DAO.Database
Dim qd As QueryDef
Set db = CurrentDb()
Dim rs As DAO.Recordset
Set qd = db.QueryDefs("qryFillCDays")
qd!FindMonth = Format([scrCDate], "mm")
qd!FindYear = Me.txtYear
Set rs = qd.OpenRecordset()
Dim Done As Integer
Done = 0
If rs.EOF And rs.BOF Then
  Else
  Do Until rs.EOF
  If Trim(rs!NameActivity & "") = "" Then
    Else
    ans = ""
    For irow = 1 To 6
      For icol = 0 To 9
        tuseday = rs!Day
        tcheckday = Trim(Left(Me("lbl" & irow & icol), 2))
        If tcheckday = tuseday Then
                Me("lbl" & irow & icol) = Me("lbl" & irow & icol) & vbCrLf
& rs!NameActivity
                Me("lbl" & irow & icol).FontWeight = 500
        End If
        If Done = 1 Then Exit For
      Next icol
       If Done = 1 Then Exit For
     Next irow
   End If

   rs.MoveNext
   Done = 0
 Loop
End If
rs.Close
End Function

Sub RefDates()
'Adapted from code by Joshua Painter whom I can't find

   Dim D1 As Variant, D2 As Integer, D3 As Integer

   Me.txtMonth = Format(Me![scrCDate], "mmmm")   'Sets the Month
   Me.txtYear = Format(Me![scrCDate], "yyyy")    'Sets the Year

   D1 = DateSerial(Year(Me![scrCDate]), Month(Me![scrCDate]), 1)  'Sets the
first day of the month
   D2 = DatePart("w", D1, vbSunday)    'Sets the first day of the week
   Do Until DatePart("w", D1, vbSunday) = 1    'Starts the calendar on the
first day of the week designated
       D1 = DateAdd("d", -1, D1)
   Loop
   Me![scr1Date] = D1
   D3 = 1
   Do Until D3 > 42    'Goes thru all the calendar days setting the dates
       Me("lbl" & Format(D3, "00")) = Day(D1) 'Starts the calendar days

   'If Month(D1) <> Month(Me![scrCDate]) Then  <--- I remmed out, will
adjust whe I get it working.
       'Me("lbl" & Format(D3, "00")).Visible = False
   'Else
       'Me("lbl" & Format(D3, "00")).ForeColor = 0
       'Me("lbl" & Format(D3, "00")).Visible = True
   'End If

   D3 = D3 + 1
   D1 = DateAdd("d", 1, D1)
   Loop
End Sub

Signature

Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II

>> Dirk,
>>
[quoted text clipped - 9 lines]
> begin executing naturally, and will stop at the breakpoint.  From that
> point you can single-step through the code in the usual way.
Douglas J. Steele - 21 Jun 2007 16:36 GMT
Is it possible that tuseday is 4 and tcheckday is 04 (or vice versa)?

Perhaps having them as integers rather than string might be a good idea.

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> First, I keep saying form when in fact it is a report...  Regardless, the
> code worked for the 11th, 18th and 25th but nothing showed for the 4th?
Gina Whipp - 21 Jun 2007 17:28 GMT
Doug,

Okay tried that, NOW I get one item for the 4th and o the 11th, 18th and
25th I get 2 tasks which is correct.  On the 4th I should see 7 activities.

Signature

Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II

> Is it possible that tuseday is 4 and tcheckday is 04 (or vice versa)?
>
> Perhaps having them as integers rather than string might be a good idea.
>
>> First, I keep saying form when in fact it is a report...  Regardless, the
>> code worked for the 11th, 18th and 25th but nothing showed for the 4th?
Douglas J. Steele - 21 Jun 2007 17:49 GMT
I thought you originally indicated that your query returned 5 events:

> I have looked at the underliing query which shows 5 lines on several days
> but I am only getting the first line.  And yes they are text boxes.

1 for the 4th, 1 for the 11th, 1 for the 18th and 2 for the 25th adds up to
5.

You're not saying that a single row in the query can represent multiple
events, are you?

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> Doug,
>
[quoted text clipped - 9 lines]
>>> the code worked for the 11th, 18th and 25th but nothing showed for the
>>> 4th?
Gina Whipp - 21 Jun 2007 18:34 GMT
Doug,

I keep changing Associates....  I'll stop that.  ANYWAY, I think I found
it...

      tuseday = rs!Day
      tcheckday = Trim(Left(Me("lbl" & irow & icol), 2))

If rs!Day = 1 thru 9 then tcheckday = Trim(Left(Me("lbl" & irow & icol), 1))
<--- see 1
If rs!Day = 10 thru whatever then tcheckday = Trim(Left(Me("lbl" & irow &
icol), 2))  <---see 2

ow I just have to write that into the code and I think it will work!  I
tried:

       If rs!cDay = 1 Or 2 Or 3 Or 4 Or 5 Or 6 Or 7 Or 8 Or 9 Then
           tcheckday = Trim(Left(Me("lbl" & irow & icol), 1))
       Else
           tcheckday = Trim(Left(Me("lbl" & irow & icol), 2))
       End If

And that didn't work but that was just test number 1!

Signature

Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II

>I thought you originally indicated that your query returned 5 events:
>
[quoted text clipped - 20 lines]
>>>> the code worked for the 11th, 18th and 25th but nothing showed for the
>>>> 4th?
Gina Whipp - 21 Jun 2007 18:40 GMT
Doug,

This seems to work...

       If rs!cDay <= 9 Then
           tcheckday = Trim(Left(Me("lbl" & irow & icol), 1))
       Else
           tcheckday = Trim(Left(Me("lbl" & irow & icol), 2))
       End If

Signature

Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II

> Doug,
>
[quoted text clipped - 45 lines]
>>>>> the code worked for the 11th, 18th and 25th but nothing showed for the
>>>>> 4th?
Gina Whipp - 21 Jun 2007 18:56 GMT
Without your questions and making me 'study' the code I would still be
pulling my hair out!
Signature

Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II

> Doug,
>
[quoted text clipped - 56 lines]
>>>>>> the code worked for the 11th, 18th and 25th but nothing showed for
>>>>>> the 4th?
Gina Whipp - 21 Jun 2007 15:05 GMT
It also dawns o me you have no idea how I fill the calendar, so here you
go...

Sub RefDates()
'Adapted from code by Joshua Painter whom I can't find

   Dim D1 As Variant, D2 As Integer, D3 As Integer

   Me.txtMonth = Format(Me![scrCDate], "mmmm")   'Sets the Month
   Me.txtYear = Format(Me![scrCDate], "yyyy")    'Sets the Year

   D1 = DateSerial(Year(Me![scrCDate]), Month(Me![scrCDate]), 1)  'Sets the
first day of the month
   D2 = DatePart("w", D1, vbSunday)    'Sets the first day of the week
   Do Until DatePart("w", D1, vbSunday) = 1    'Starts the calendar on the
first day of the week designated
       D1 = DateAdd("d", -1, D1)
   Loop
   Me![scr1Date] = D1
   D3 = 11
   Do Until D3 > 52    'Goes thru all the calendar days setting the dates
       'Me("lbl" & Format(D3, "00")) = Day(D1) 'Starts the calendar days
       Me("lbl" & D3) = Day(D1)    'Starts the calendar days

   If Month(D1) <> Month(Me![scrCDate]) Then
       Me("lbl" & D3).Visible = False
   Else
       Me("lbl" & D3).ForeColor = 0
       Me("lbl" & D3).Visible = True
   End If

   D3 = D3 + 1
   D1 = DateAdd("d", 1, D1)
   Loop
End Sub

Signature

Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II

>> Dirk,
>>
[quoted text clipped - 6 lines]
> through it line by line, when you know it's working on a day that should
> have several lines.
 
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.