|
-
Sep 13th, 2007, 07:22 AM
#1
Thread Starter
New Member
Help Me Please!!!
help me please. im working on a program that displays a datareport containing the contents of my database. but when i have two or more recordsets in my database, the datareport shows all the contents of my database. for example, i have a field named "personName" in the database, and when personName field has two or more names in it, the datareport displays all the name in the personName field.. can anyone please help me, i really need to finish this program... HELP ME PLEASE!
-
Sep 13th, 2007, 10:59 AM
#2
Re: Help Me Please!!!
What programming language?
What type of database?
Do you mean your trying to display the contents of a table and you only want to show 1 record on the report?
-
Sep 13th, 2007, 11:01 AM
#3
Thread Starter
New Member
Re: Help Me Please!!!
oh i forgot, im using vb6.0 and may database is microsoft access. yup you're right.im trying to display only one recordset form the database.but it displays all the records. i mean, for example:
fieldName = "personName", "personName" contains "mark", "joe", "mike".. i only want to display "mike" but all three names are being displayed..
Last edited by gibe; Sep 13th, 2007 at 11:04 AM.
-
Sep 13th, 2007, 11:59 AM
#4
Re: Help Me Please!!!
do u mean that u only want to display 1 record from the recordset?
When you create the recordset it should only contain the records that you want the report to display.
Like - "select personName from tblNamedata where personName = 'mark'"
-
Sep 14th, 2007, 06:07 AM
#5
Thread Starter
New Member
Re: Help Me Please!!!
ummm, ok.. i made another program (that is, in order for me not to ruin my other one). its just a trial program for my problem. i have this code on my form
Code:
Private Sub Command1_Click()
Adodc1.Recordset.AddNew
Text1.SetFocus
End Sub
Private Sub Command2_Click()
Adodc1.Recordset![nme] = Text1.Text
End Sub
Private Sub Command3_Click()
Adodc1.Recordset.Delete
MsgBox "record deleted!"
End Sub
Private Sub Command4_Click()
DataReport1.Show
End Sub
i first click the command1 in order for me to add a name, then i click command2 to save the name i entered, but when i have entered and saved two names, and i click command4, the datareport shows the two names that i entered, for example:
name: mark
name: mike
that's what's on my datareport, what should i do if i only want to display one name?
P.S. i have, on my project, a form, a DataEnvironment and a DataReport. please tell me what to do...
-
Sep 14th, 2007, 11:44 AM
#6
Re: Help Me Please!!!
You need to design your dataenvironment to use a parameter, then send the parameter to the DE before running the report.
Code:
If de1.rsCommand1.State = adStateOpen Then
de1.rsCommand1.Close
End If
de1.Commands("Command1").Parameters("param1").Value = text1.text
rpt1.Show
I'm sure if you search the forum there will be detailed discussion on this process.
-
Sep 15th, 2007, 10:19 PM
#7
Thread Starter
New Member
Re: Help Me Please!!!
ummm. where do i put the code?
-
Sep 16th, 2007, 12:51 AM
#8
Re: Help Me Please!!!
You put the code where ever you call the report from, like a command button.
In the DE command properties you need to setup a sql, like
select * from YOURTABLE where nme = ?
The '?' is where the parameter you send will be inserted.
then select the parameter tab and name the parameter "param1"
The report will only display the records for the people whose name matches the value of "param1", which you set right before rpt.show is executed, see the prior post I sent.
-
Sep 16th, 2007, 06:55 AM
#9
Thread Starter
New Member
Re: Help Me Please!!!
how can i rename the parameter? when i put the sql command on the sql statement textbox and i go to the parameters tab, nothing is in there, and i cant type anything on the textboxes under the parameters tab..
Last edited by gibe; Sep 16th, 2007 at 07:09 AM.
-
Sep 16th, 2007, 11:54 AM
#10
Re: Help Me Please!!!
Are you using the '?' in your sql?
Code:
select * from tags where datereceived=? order by tagnumber
This is a sql from one of my DE
-
Sep 17th, 2007, 09:46 PM
#11
Thread Starter
New Member
Re: Help Me Please!!!
ok i got it.thanks so much but i have a question..
why is it that when i add and save a record, and i click the button that shows the report, it doesnt contain anything. but when i scroll to another recordset, and i scroll it back, that is only the time that the report shows it.
its like this.. i clicked the add button, entered "mike" in the textbox and clicked the save button. but when i clicked the show report button, it doesnt contain anything, its just a blank page. so i closed the datareport window and i scrolled the Adodc1 control, then i scrolled it back to the previous recordset, this time when i clicked the show report button, the page already contains the records...
how can i show the record without scrolling the Adodc1 control back and forth?
-
Sep 18th, 2007, 11:27 AM
#12
Re: Help Me Please!!!
There are acouple of things you can try.
Close the DE recordset
Code:
If de.rsCommand1.State = adStateOpen Then
de.rsCommand1.Close
End If
rpt.show
You would replace rsCommand1 ine the code above with the name of the recordset in your DE. The recordset name is the command name with a "rs" in front of it. ( command name is "Names" then recordset name is "rsName"
or try requerying the recordset
rpt1.show
de.rsCommand1.requery
Last edited by wes4dbt; Sep 18th, 2007 at 12:06 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|