Results 1 to 10 of 10

Thread: problem writing report

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2007
    Posts
    7

    problem writing report

    i have database which have two tables (customers & table1)
    customer has two field customerid & customername
    table1 has eight field in which two field are customerid and date
    my problem is this when i retrive data of a customerid between datefrom to dateto in datagrid it will show the data beween datefrom to dateto
    but when i am trying to make report acording to this criteria then report shows all the data of that customerid from start to end NOT show between datefrom to dateto
    i am using this sql statement to retrive data in datagrid
    {"SELECT * FROM Table1, Customers WHERE Customers.CustomerID =Table1.CustomerID AND Table1.CustomerID =" & Customerid & " and Table1.Date between #" & dtFrom & "# and #" & dtTo & "# ORDER BY Table1.DATE"}
    is any one can help me in this problem

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: problem writing report

    Are you using VB6 or VB.NET?

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2007
    Posts
    7

    Re: problem writing report

    i am using visual basic 6 and for database i use access 97

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: problem writing report

    Then put two option buttons on your VB6 form.

    Call one of the optAll and put in the caption "All Records"
    Call the other one optDates and put in the caption "Select Date Range"

    Then in your code do something like
    Code:
    If optDates.Value = True Then
    {"SELECT * FROM Table1, Customers WHERE Customers.CustomerID =Table1.CustomerID AND Table1.CustomerID =" & Customerid & " and Table1.Date between #" & dtFrom & "# and #" & dtTo & "# ORDER BY Table1.DATE"}
    Else
    {"SELECT * FROM Table1, Customers WHERE Customers.CustomerID =Table1.CustomerID AND Table1.CustomerID =" & Customerid 
    End If

  5. #5

    Thread Starter
    New Member
    Join Date
    Aug 2007
    Posts
    7

    Re: problem writing report

    i use this code in viewing the data for customerid
    but in report print the data show in datagrid does not same in report
    in report show all data of that customerid NOT equal to the datagrid

  6. #6
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,024

    Re: problem writing report

    HI,

    Are you using CR or data report?

    greg
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

  7. #7
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,024

    Re: problem writing report

    If your using data report, you may use hack's sql statement suggestion to view your report.

    Greg
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

  8. #8
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: problem writing report

    You have very little control over what is shown in a bound DataGrid.

    Because it is a bound control, and therefore, linked to a table, it is going to display everything in the table.

    If you need, for display purposes, only a subset of your records, then you would be much better off changing from using a datagrid to an unbound control like a flexgrid or a ListView.

  9. #9
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,513

    Re: problem writing report

    What are you using for the DataSource Property of your report. Are you using a DE , ADO recordset or MSDataShape?

  10. #10

    Thread Starter
    New Member
    Join Date
    Aug 2007
    Posts
    7

    Re: problem writing report

    I try to use both CR 8 And Datareport
    but both have same problems
    and i am using ADODB recordset

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