S
SG
I have a form called Print Dialogue
On this for I have 2 unbound Text boxes 1 called StartDate and the other
called EndDate, also on this form I have a commandbutton
The following code is attached the onload event of the form ...
Private Sub Form_Load()
Dim DateRange As New Recordset
DateRange.Open _
"SELECT Min(DateValue(InvoiceDate)) as SDate," & _
"Max(DateValue(InvoiceDate)) as Edate " & _
"From tblinvoice", _
CurrentProject.Connection
Me.Startdate = DateRange!Sdate
Me.EndDate = DateRange!EDate
End Sub
And behind the Onclick even of the command button...
Private Sub Command4_Click()
Dim ReportName
ReportName = "SalesReport1"
DoCmd.OpenReport _
ReportName:=ReportName, _
view:=acViewPreview, _
WhereCondition:="InvoiceDate Between #" & _
Me.Startdate & "# AND #" & _
Me.EndDate & "#"
End Sub
The problem I have with the above is when I click on the command button I
get an MS Access has encountered a problem and needs to close message??
Can anyone help me out on this one, I've checked the code over and over and
cant seem to find a problem.
Thanks in advance
S
On this for I have 2 unbound Text boxes 1 called StartDate and the other
called EndDate, also on this form I have a commandbutton
The following code is attached the onload event of the form ...
Private Sub Form_Load()
Dim DateRange As New Recordset
DateRange.Open _
"SELECT Min(DateValue(InvoiceDate)) as SDate," & _
"Max(DateValue(InvoiceDate)) as Edate " & _
"From tblinvoice", _
CurrentProject.Connection
Me.Startdate = DateRange!Sdate
Me.EndDate = DateRange!EDate
End Sub
And behind the Onclick even of the command button...
Private Sub Command4_Click()
Dim ReportName
ReportName = "SalesReport1"
DoCmd.OpenReport _
ReportName:=ReportName, _
view:=acViewPreview, _
WhereCondition:="InvoiceDate Between #" & _
Me.Startdate & "# AND #" & _
Me.EndDate & "#"
End Sub
The problem I have with the above is when I click on the command button I
get an MS Access has encountered a problem and needs to close message??
Can anyone help me out on this one, I've checked the code over and over and
cant seem to find a problem.
Thanks in advance
S