Results 1 to 8 of 8

Thread: Selection criteria not working!!!

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Selection criteria not working!!!

    I am using CR 8.5. I have a TimeSheet report in which I only want to report on the selected employee. For test purposes, I have 14 records of one employee and 1 record for another employee. However, my report shows all the records instead of the employee I select. I don't know if I need to adjust the setting in the report or my SQL statement. I have attached my code below.

    VB Code:
    1. Private Sub PrintTimeSheet()
    2.     Dim oApp As CRAXDRT.Application
    3.     Dim oReport As CRAXDRT.Report
    4.  
    5.     mSQL = "Select  A.*, " & _
    6.                    "B.*, " & _
    7.                    "C.* " & _
    8.              "From tblTime A, " & _
    9.                   "tblPayPeriods B, " & _
    10.                   "tblProjects C " & _
    11.             "Where (A.ppID = B.ppID) and " & _
    12.                   "(A.projectID = C.prjInternalProjID) and" & _
    13.                   "(A.employee = '" & mstrEmployee & "') " & _
    14.             "Order By A.employee, A.projectID"
    15.  
    16.     If OpenDBConnection Then
    17.         Set rs = New ADODB.Recordset
    18.         Set rs = cn.Execute(mSQL)
    19.         Set oApp = New CRAXDRT.Application
    20.         Set oReport = oApp.OpenReport("C:\Reports\rptTimeSheet.rpt", 1)
    21.         oReport.Database.SetDataSource rs, 3, 1
    22.         frmReport.cr1.ReportSource = oReport
    23.         frmReport.cr1.ViewReport
    24.     End If
    25. End Sub

    The key is the mstrEmployee field. That value is what makes the entire report unique.

    Thanks,

    -Blake
    Blake

  2. #2
    Frenzied Member pnish's Avatar
    Join Date
    Aug 2002
    Location
    Tassie, Oz
    Posts
    1,918

    Re: Selection criteria not working!!!

    Make sure you don't have Save Data With Report checked in your report. You'll find that option either on the File menu or under Report Options on the file menu.

    If that doesn't help, check how many records you're passing to the report in the recordset and make sure it only contains the record(s) you want.
    Pete

    No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Selection criteria not working!!!

    Pete,

    This think isn't even working at all now. I specified a new query with a date parameter in it and it still pulls all the records when it shouldn't pull any now. Not sure what I'm doin' wrong. Here's is my current SQL statement:

    VB Code:
    1. Private Sub PrintTimeSheet()
    2.     Dim oApp As CRAXDRT.Application
    3.     Dim oReport As CRAXDRT.Report
    4.  
    5.     mSQL = "Select  A.*, " & _
    6.                    "B.*, " & _
    7.                    "C.* " & _
    8.              "From tblTime A, " & _
    9.                   "tblPayPeriods B, " & _
    10.                   "tblProjects C " & _
    11.             "Where (A.sessionDate = #" & Format(Now, "mm/dd/yyyy") & "#) and " & _
    12.                   "(A.ppID = B.ppID) and " & _
    13.                   "(A.projectID = C.prjInternalProjID) and " & _
    14.                   "(A.employee = '" & mstrEmployee & "') " & _
    15.             "Order By A.employee, A.projectID"
    16.    
    17.     Debug.Print mSQL
    18.    
    19.     If OpenDBConnection Then
    20.         Set oApp = New CRAXDRT.Application
    21.         Set rs = New ADODB.Recordset
    22.         rs.Open mSQL, cn, adOpenKeyset, adLockPessimistic
    23.         Set oReport = oApp.OpenReport("C:\Reports\rptTimeSheet.rpt", 1)
    24.         oReport.Database.SetDataSource rs, 3, 1
    25.         frmReport.cr1.ReportSource = oReport
    26.         frmReport.cr1.ViewReport
    27.     End If
    28. End Sub

    Thanks,

    Blake
    Last edited by blakemckenna; Dec 16th, 2006 at 02:45 PM.
    Blake

  4. #4
    Frenzied Member pnish's Avatar
    Join Date
    Aug 2002
    Location
    Tassie, Oz
    Posts
    1,918

    Re: Selection criteria not working!!!

    When you say 'it pulls all the records' do you mean the recordset or the report? Does your report also have a connection to the database or is it only getting its data from the recordset you're passing?

    When you execute your query, how many records does it contain? If it contains no records but your report is still displaying all the records, it means either you have saved the data with the report (as I mentioned before) or the report is getting the data from somewhere else, ie directly from a database connection.

    One thing you could try so you can see where the data's coming from would be to make a copy of your database, totally change the data in the tables and execute your query off this copied database. Does the report show the new, changed data or is it still showing the original data?
    Pete

    No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Selection criteria not working!!!

    Pete,

    Your idea is a good one and I'm going to try it. However, I now have another problem with the same report. I get the error "Server has not yet been opened". It just started so I don't know exactly what I did wrong. Any ideas on this one?

    Thanks,
    Blake

  6. #6
    Frenzied Member pnish's Avatar
    Join Date
    Aug 2002
    Location
    Tassie, Oz
    Posts
    1,918

    Re: Selection criteria not working!!!

    I haven't seen that one before. Ae you using a secured Access database?
    If you want to zip up your project and send it to me I could take a look for you. Don't forget to include the database and .rpt file.
    Pete

    No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.

  7. #7

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Selection criteria not working!!!

    Pete,

    I know how to reply with an email...but how do you send attachments?
    Blake

  8. #8
    Frenzied Member
    Join Date
    Aug 2006
    Location
    India, Punjab, Bhatinda
    Posts
    1,689

    Re: Selection criteria not working!!!

    Scroll down this page you will find "Go Advanced" button, Click. In the next page scroll down, you will find another button "Manage Attachments" Click. In the following page you will find a button "Browse", click and select the file to upload. Then click "Upload" button. After you see your files in the window, click "Close Window". Now your files are attached to your post. Note: Not all types of files can be uploaded. The supported files list is in the window where you find "Upload" button.

    If u wnat to attach files from ur email client like, yahoo, Gmail, etc. then u will find button somewhere which says something like "Attach files" after u click on the compose button.
    Hope I was helpful.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width