Question

Calendar

I am developing a customized calendar on access. The image above is a snippet of what im trying to do, each "box" is a subform of a form [cell] that is linked to a table that has appointments as entries. I want all subforms under monday to each show an appointment for Monday and same for Tuesday and so on to have a weekly appointment calendar. I must point out that all these subforms are of the same form [cell] I just want them to show different records.

I have been trying to update/change data on load in the subforms with no success, its giving me an sql statement error, doesnt recognize its an sql statement.

Also I dont want to have an SQL statement for each subform as it will be 25(5 subforms per day) sql queries running and im sure it will really slowdown the program. How can I make it more efficient, use less sql statements. Here is my initial code for the first cell

Dim sqlstring As String
sqlstring = "SELECT CallB_Schedule.InternName, CallB_Schedule.ClientName,              CallB_Schedule.ClientPhone, CallB_Schedule.Time FROM CallB_Schedule WHERE  (WEEKDAY(CallB_Schedule.InternName) = 2)"
DoCmd.RunSQL (sqlstring)
Forms!Schedule!schedule_cell_monday.Form!InternName = InternName
Forms!Schedule!schedule_cell_monday.Form!Time = Time
Forms!Schedule!schedule_cell_monday.Form!ClientName = ClientName
Forms!Schedule!schedule_cell_monday.Form!ClientPhone = ClientPhone

Where Schedule is the main form and schedule_cell_monday is one of the subforms on Schedule

Was it helpful?

Solution

You are not setting the recordsource of the sub form in the code you have given. You could replace

DoCmd.RunSQL (sqlstring)

with

Forms!Schedule!schedule_cell_monday.Form.recordsource = sqlstring

The code to run the sql statement is often reserved for action queries.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top