Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Database and Reporting > VB6 Data Report Query


Reply
 
Thread Tools Display Modes
  #1  
Old 01-13-2003, 06:20 AM
NitrO
Guest
 
Posts: n/a
Default VB6 Data Report Query


Hi all,

I might just be being dense, but does anyone know how to suppress duplicate data within the detail section of a data report.

Example:
I have a recordset which contains -
CustName, Cust ID, PurchDate, Item1, Item2, Item3, Item4
CustName, Cust ID, PurchDate, Item1, Item2, Item3, Item4
---- " ------
etc, etc....

I need to suppress CustName & ID, so I only have 1 occurance showing.

Any help or suggestions greatly appreciated.

NitrO
Reply With Quote
  #2  
Old 01-13-2003, 07:10 AM
FrogMan's Avatar
FrogMan FrogMan is offline
Centurion
 
Join Date: Oct 2001
Location: Oxford, UK
Posts: 184
Default

Hi

Do you mean your report needs to look like something this

CustName Cust ID

PurchDate,Item1,Item2,Item3,Item4

or are you actually trying supress duplicate data ?
Reply With Quote
  #3  
Old 01-13-2003, 07:46 AM
NitrO
Guest
 
Posts: n/a
Default

FrogMan,

Yeah, with CustName & ID only appearing once, with all other data listing underneath.

NitrO
Reply With Quote
  #4  
Old 01-13-2003, 08:07 AM
FrogMan's Avatar
FrogMan FrogMan is offline
Centurion
 
Join Date: Oct 2001
Location: Oxford, UK
Posts: 184
Default

Are you using DataEnvironment ?
Reply With Quote
  #5  
Old 01-13-2003, 09:06 AM
NitrO
Guest
 
Posts: n/a
Default

No but I can if it makes it easier.

I should also point out that I am using an sql query, which uses a variable populated from a combo box on a form.

Last edited by NitrO; 01-13-2003 at 09:16 AM.
Reply With Quote
  #6  
Old 01-13-2003, 09:58 AM
FrogMan's Avatar
FrogMan FrogMan is offline
Centurion
 
Join Date: Oct 2001
Location: Oxford, UK
Posts: 184
Default

Yep, DataEnvironment will make it easier. As for using a variable SQL query, it won't make any difference to the layout of the report.

Ok, the best way I have found (which doesn't mean it's the only way) is to set up a query with a child query in the dataenvironment.

Set the first sql query to just pass CUST NAME and CUSTID then from this query set a child query and select all fields.

From there you can set the DataReports datasource to the dataenvironment and set the datamember to the SQL query.

Then in the datareport right click the grey square in the top left hand corner and select retreive structure.

This will set up relevent sections for your report based on the query you have set up. You can then put CUSTNAME and CUSTID in the group header section and the rest of the information in the detail section.

Hope this helps
Reply With Quote
  #7  
Old 01-13-2003, 10:33 AM
NitrO
Guest
 
Posts: n/a
Default

Thanks, worked a treat, however how do I feed in the query's parameter?

i.e. WHERE CustName = ' " & theName & " '

I've tried the parameters tab of the commands properties but it is all disabled and will not allow me to add anything?

NitrO
Reply With Quote
  #8  
Old 01-14-2003, 03:13 AM
FrogMan's Avatar
FrogMan FrogMan is offline
Centurion
 
Join Date: Oct 2001
Location: Oxford, UK
Posts: 184
Default

Hi

Ok, it's best to do it at run time.

Firstly I would get the structure of the SQL command. The reason for this is so you can copy it into your programme. I do something like this.

With DE1
Open "c:\temp\sql.txt" For Output As #1
Print #1, .Commands("sqlCheckDates").CommandText
Close #1
End With

This creates a text file with your sql in. You will then see that heirarchical queries are created using SHAPE.

You can then discard this code.

Then you can store the sql in a variable and add your parameters where you like.

You then set the CommandText to your variable. Something like this :
strSQL = YourSQL
With DE1
.Commands("sqlCheckDates").CommandType = adCmdText
.Commands("sqlCheckDates").CommandText = strSQL
.Commands("sqlCheckDates").Execute
End With

Hope this helps
Reply With Quote
  #9  
Old 01-14-2003, 03:22 PM
NitrO
Guest
 
Posts: n/a
Default

Thanks, for the help Frogman

It worked a treat.

Cheers,

NitrO
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->