Yes.
Each report requires a data member or data source. In your data environment, define a command object and specify your SQL statement to pull the fields you need. When you create a datareport, assign the command object to the datareport and you will be able to insert the fields into the datareport. Scott
Programmer Analyst
this i know.my problem is that i want to get data from two tables in one data report.the two tables doesnot have any relation.they are totally seperate.i am using ms access as a database.since i have norelation in my tables so i have to apply two seperate sql query for both tables.
now i don't know how to write two seperate sql statements under one command so that i will able to drag the results of both sql statements in one data report
this is close to my problem.i want to write sql query for calculating the total no of records in one table and then i have to write the sql query for calculating the total no of records in second table.how i will write it?????????
What you're wanting to do is possible using a Parent and Child command objects. Although, (you knew this was coming) I am 99.99% positive a relation must exist between the two tables. Below is an example that contains a relation.
Other possible solutions for you. Can you generate the report in HTML or Word? These formats would give you better flexibility......just a suggestion. Scott
Programmer Analyst
put a 2 label objects in page header(section 2) in datareport
and connect the any one of ur database table thru command1 in dataconnection and put it as datareport's data member.
then put the 2 label's names as count1 and count2
in the form put a button and write this code
________________________________________
Private Sub Command2_Click()
Set db = OpenDatabase(App.Path & "\sample.mdb"
Set rs = db.OpenRecordset("select count(*) from xooline"
Set rs2 = db.OpenRecordset("select count(*) from second"
DataReport1.Sections("section2".Controls.Item("count1".Caption = rs(0)
DataReport1.Sections("section2".Controls.Item("count2".Caption = rs2(0)
DataReport1.Show
End Sub
_____________________________
this is the another way to assing the values for datareport labels from forms.
there is one more problem that how i will write the sql query if i want the sql query on two fields belonging to one tables.
for one field "name" i will write this(given below) query now i want this similar query for another field "slot"
i want to write only one query for both this fields
i.e under one command so that i will be able to include the results of both query in one data report
select name,count(*)from mdialogic group by name order by 2 desc
there is one more problem.i am having one table "object" .in this table there is one field called "name".In this field i am having diffrent entries like modem,telephone,stablizer etc.now i want that when i write the code as u told me in the form it will automatically generate the labels in the data report for all the items i am having in the field "name"
for dialogic and computer i know this will be the entry but for modem,telephone etc i don't know how many items are there in the name field what are there labels so i cant just include labels in the report i want they automatically generate the no of labels in the data report by counting the no of diffrent no of items in "name" and also label.caption =the name of the item
in order to get this type of output i have used "select count(distinct name)from object" in the form but it will gave the error in distinct name
ok put two labels on the datareport and change their properties -Cangrow = T
Set db = OpenDatabase(App.Path & "\sample.mdb"
Set rs = db.OpenRecordset("select count(*) from xooline"
Set rs2 = db.OpenRecordset("select count(*) from second"
' add your field1 values from database thru while loop here i put some dummy names
a = "name1" + Chr(13) + Chr(13) + Chr(13) + "name2" + Chr(13) + Chr(13) + "name3"
'similarly second field
b = "2" + Chr(13) + Chr(13) + "12" + Chr(13) + Chr(13) + "15"
' assign the variables to labels
DataReport1.Sections("section2".Controls.Item("count1".Caption = a
DataReport1.Sections("section2".Controls.Item("count2".Caption = b
DataReport1.Show
i could not able to understand ur code can u give me ur mail id so i mail my report and form to u can write the code in them.in that i also explain exactly what i want
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.