Continuous forms, list box works, but i want to use subforms
Sami Shamma 4 months ago
you need Subforms to do conditional formatting.
Kevin Robertson 4 months ago
I did this last year. The subforms had no Recordsource.
I wrote the following sub to add the Recordsource to each subform dynamically.
Private Sub SetDay()
Dim mySQL As String, whereStr As String, S As String, X As Long
mySQL = "SELECT * FROM AppointmentQ WHERE "
For X = 1 To 42
S = "Day" & X
whereStr = "DateTime>=#" & StartDate + (X - 1) & "# AND DateTime<#" & StartDate + X & "#"
Me.Controls(S).Form.RecordSource = mySQL & whereStr
Next
End Sub
I called this sub in the Load event of the Calendar Form.
Sami Shamma 4 months ago
Kevin,
I love this approach. it will make life easier. I wish I knew how to this before a coded the 42 subforms.
Steven VerhaegenOP 4 months ago
So you can use the same subform everytime? -> i make a form as a Continuous form and copy it 42 times in the mainform and name them day1, day2 like the listboxes? (excuse me for my English, I'm Dutch (Flemish) speaking)
The last image shows the use of Subforms instead of Listboxes.
Steven VerhaegenOP 4 months ago
That's how i want it to be.
Steven VerhaegenOP 4 months ago
I'm doing something wrong with the where part.
Kevin Robertson 4 months ago
Please share what you have. We can't troubleshoot your problem if we can't see it. Saying that though, check your spacing. Missing just one space is enough to make the code not work.
Steven VerhaegenOP 3 months ago
My apologies for the late reply. But I was away on vacation. I got it working. So thanks to all for the help
Sorry, only students may add comments.
Click here for more
information on how you can set up an account.
If you are a Visitor, go ahead and post your reply as a
new comment, and we'll move it here for you
once it's approved. Be sure to use the same name and email address.
This thread is now CLOSED. If you wish to comment, start a NEW discussion in
Calendar Seminar Lessons.
The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.