I have a calendar form to show appointments.There is a textbox to show the day and a listbox for each day to view the appointments. When the user clicks the company name the appointments form opens to show the customer info & notes.
This is the code to open the calendar
Private Sub Form_Open(Cancel As Integer)
On Error Resume Next
Dim x%, ctl$
For x = 1 To 42
If month(Me("Day" & x)) <> month(Me![Date]) Then
Me("Day" & x).Visible = False
Me("list" & x).Visible = False
Else
Me("Day" & x).Visible = True
Me("day" & x).Visible = True
End If
Next x
Set Today = Me("Day" & Trim(str$(DateDiff("day", Me!WD, Date))))
Today.ForeColor = RGB(255, 0, 0)
Me!Back.SetFocus
End Sub
This is the listbox rowsource.
SELECT ContactLog.LogID, Customers.CompanyName, ContactLog.Callbackdate, ContactLog.Rep, ContactLog.Reminder
FROM Customers INNER JOIN ContactLog ON Customers.CustomerID = ContactLog.Customerid
WHERE (((ContactLog.Callbackdate)=[forms]![frmcal]![day]) AND ((ContactLog.Rep)=CurrentUser()) AND ((ContactLog.Reminder)=Yes));
Since I have 37 days the form runs 37 queries when it opens.
Can I remove the rowsource in each listbox and populate each listbox by running 1 query when the forms opens to speed it up. Any help to point me in the right direction would be appreciated.
Thanks
This is the code to open the calendar
Private Sub Form_Open(Cancel As Integer)
On Error Resume Next
Dim x%, ctl$
For x = 1 To 42
If month(Me("Day" & x)) <> month(Me![Date]) Then
Me("Day" & x).Visible = False
Me("list" & x).Visible = False
Else
Me("Day" & x).Visible = True
Me("day" & x).Visible = True
End If
Next x
Set Today = Me("Day" & Trim(str$(DateDiff("day", Me!WD, Date))))
Today.ForeColor = RGB(255, 0, 0)
Me!Back.SetFocus
End Sub
This is the listbox rowsource.
SELECT ContactLog.LogID, Customers.CompanyName, ContactLog.Callbackdate, ContactLog.Rep, ContactLog.Reminder
FROM Customers INNER JOIN ContactLog ON Customers.CustomerID = ContactLog.Customerid
WHERE (((ContactLog.Callbackdate)=[forms]![frmcal]![day]) AND ((ContactLog.Rep)=CurrentUser()) AND ((ContactLog.Reminder)=Yes));
Since I have 37 days the form runs 37 queries when it opens.
Can I remove the rowsource in each listbox and populate each listbox by running 1 query when the forms opens to speed it up. Any help to point me in the right direction would be appreciated.
Thanks