Q for MikeB on Calendar.

B

bob

I downloaded your Calendar and it is working perfectly.
I attached the selection on the report.The data on my
report is comming from whatever the user selet on the
calendar.
Is there any way I can show on the Header of the report
the date selection that user have selected from the
calendar?e.g This reprt runs between 01/01/2003 and
01/30/03.

Thank you.
 
M

MikeB

Are the date values going to textboxes on form first? If so, then in the Open event of the Report,
you can add code to refer to the textboxes on your calling form to update either Labels or TextBoxes
in the Header of your Report, maybe something like this

Private Sub Report_Open(Cancel As Integer)
lblRepBegDate.Caption = TheCallingForm.txtBegDate.Value
lblRepEndDate.Caption = TheCallingForm.txtEndDate.Value

End Sub
 
B

bob

I am getting an "Invalid qualifier" error message when I
refer to a form where the dates are comming from.

I am not good in writting code ...,but thank you Mike for
your quick respond.I was so close ...!!!
-----Original Message-----
Are the date values going to textboxes on form first? If
so, then in the Open event of the Report,
you can add code to refer to the textboxes on your
calling form to update either Labels or TextBoxes
 
M

MikeB

Bob,
Post your code [cut and paste it exactly] as well as the name of the calling form and the
textboxes...
We will be glad to help if we can see what you are doing.
 
M

MikeB

Bob,
This is the Report Code I tested (you will have to change the names to suit yours):
Option Compare Database
Dim frmCallingForm As Form

Private Sub Report_Open(Cancel As Integer)
Dim strDocName As String
strDocName = "frmDateTester"
If IsFormLoaded(strDocName) = False Then
Cancel = True
DoCmd.OpenForm "frmDateTester", acNormal, , , , acWindowNormal
Exit Sub
Else

'Here is where you didn't set an Object Reference for the calling form
Set frmCallingForm = Forms(strDocName)
With Me
.lblBeg.Caption = frmCallingForm.txtStartDate.Value
.lblEnd.Caption = frmCallingForm.txtEndDate.Value
End With
End If
End Sub

Private Function IsFormLoaded(frmName As String) As Boolean
Dim i As Integer
For i = 0 To Forms.Count - 1
If LCase(Forms(i).Name) = "frmdatetester" Then
IsFormLoaded = True
Exit For
End If
Next
End Function

Here is my Form Code:

Option Compare Database

Private Sub Command4_Click()
PrintRep "repTestDate"
End Sub

Private Sub PrintRep(repName As String)
With Me
If IsNull(.txtStartDate) Then
.txtStartDate.SetFocus
Exit Sub
End If
If IsNull(.txtEndDate) Then
.txtEndDate.SetFocus
Exit Sub
End If
End With
DoCmd.OpenReport repName, acViewPreview
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top