Re: Code not working

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



If you open your table in design view, what data type is the TOOnScene
field?

Immediately above the DoCmd.OpenReport line, see:
Debug.Print strWhere
Then when you open the report, open the Immediate Window (press Ctrl+G), and
see what it says is in the filter of the report.
Then type this into the Immediate Window:
? Reports!DailyDispatch.Filter

Hopefully that will help you to track down what is happening.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Jen" <Jen@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:364E27E7-470B-45F7-AEF1-04C97AE8C33C@xxxxxxxxxxxxxxxx
> Okay I got this off the internet and followed all the directions, it opens
> my
> report but displays all the dates not specific days. Please Help.....
>
>
> Private Sub Command4_Click()
>
> Dim strReport As String
> Dim strField As String
> Dim strWhere As String
> Const conDateFormat = "\#mm\/dd\/yyyy\#"
>
> strReport = "DailyDispatch"
> strField = "TOOnScene"
>
> If IsNull(Me.txtstartdate) Then
> If Not IsNull(Me.txtEndDate) Then
> strWhere = strField & " < " & Format(Me.txtEndDate,
> conDateFormat)
> End If
> Else
> If IsNull(Me.txtEndDate) Then
> strWhere = strField & " > " & Format(Me.txtstartdate,
> conDateFormat)
> Else
> strWhere = strField & " Between " & Format(Me.txtstartdate,
> conDateFormat) _
> & " And " & Format(Me.txtEndDate, conDateFormat)
> End If
> End If
>
> DoCmd.OpenReport strReport, acViewPreview, , strWhere
>
> End Sub
>
> Private Sub Command5_Click()
>
> DoCmd.Close acForm, Me.Name
>
> End Sub
>


.



Relevant Pages

  • RE: Error 2455 on close of db
    ... occurs when you exit this form in this way. ... I do have a split db with a hidden form that opens when the database does to ... Private Sub Form_Unload ...
    (microsoft.public.access.formscoding)
  • RE: Error 2455 on close of db
    ... occurs when you exit this form in this way. ... I do have a split db with a hidden form that opens when the database does to ... Private Sub Form_Unload ...
    (microsoft.public.access.formscoding)
  • RE: Error 2455 on close of db
    ... "Jack Leach" wrote: ... I do have a split db with a hidden form that opens when the database does to ... Private Sub Form_Unload ...
    (microsoft.public.access.formscoding)
  • Re: DCount count records based on field value?
    ... error (because it always opens in a new record). ... Private Sub Command116_Click ... Dim stDocName As String ... If ID is not a field in the form frmReportDocLinks then that might generate ...
    (microsoft.public.access.modulesdaovba)
  • Re: How trigger VBScript events in VBA ?
    ... > 2 I need make some task when a user opens mail from a folder. ... > collection of MailItem objects"? ... > Private Sub myMailItems_Open ...
    (microsoft.public.outlook.program_vba)