954,153 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Retrieving query records on datareport

SIR ,

I WANT IF USER CLICK ON PRINT BUTTON ALL THE RECORDS SHOULD
COME IN A REPORT FROM MR QUERY
Product_tabletest.zip



BUT RECORDS ARE NOT SHOWING ON DATA REPORT.

I HAVE WRITTEN A CODE IN PRINT_CLICK

Private Sub Command4_Click()Set rs = New adodb.Recordset
rs.Open " select * from MR query", con, adOpenDynamic, adLockOptimistic
Set DataReport2.DataSource = rs
DataReport2.Orientation = rptOrientLandscape
DataReport2.Show
End Sub

Attachments Product_tabletest.zip (148.83KB)
firoz.raj
Posting Pro in Training
415 posts since Dec 2008
Reputation Points: 7
Solved Threads: 1
 

hi did you input an riptextbox in your data report?

regards
Ryan Riel

ryan311
Posting Whiz in Training
254 posts since Jul 2008
Reputation Points: 3
Solved Threads: 5
 

hi did you input an riptextbox in your data report?

regards Ryan Riel


yes i have taken a textbox i am getting error datafield is empty
and datasource not found

firoz.raj
Posting Pro in Training
415 posts since Dec 2008
Reputation Points: 7
Solved Threads: 1
 

can u tell me what is the equivalent of the emp_id, dept_name, etc in the riptextbox of your datareport thanks

ryan311
Posting Whiz in Training
254 posts since Jul 2008
Reputation Points: 3
Solved Threads: 5
 
yes i have taken a textbox i am getting error datafield is empty and datasource not found


i don't know MR table is not comming in object name in command2
properties dialog box

firoz.raj
Posting Pro in Training
415 posts since Dec 2008
Reputation Points: 7
Solved Threads: 1
 

yes because you did not add an item to your data report, you should add an item in your data report like this way:

With datareport2.Sections("Section1").Controls
.Item("Text1").DataField = rs.Fields("Emp_file").Name
end with
set datareport2.datasource = rs

regards
Ryan

ryan311
Posting Whiz in Training
254 posts since Jul 2008
Reputation Points: 3
Solved Threads: 5
 

in which event should i write this code when i go in code window of data report
i got only
activate
deactivate
error
initialize event in which event should i write this code

firoz.raj
Posting Pro in Training
415 posts since Dec 2008
Reputation Points: 7
Solved Threads: 1
 

where should i write
i have written in print_click but it is not working
Private Sub Command4_Click()
Set rs = New adodb.Recordset
rs.Open " select * from MR query", con, adOpenDynamic, adLockOptimistic
Set DataReport2.DataSource = rs
DataReport2.Orientation = rptOrientLandscape
'With DataReport2.Sections("Section1").Controls
'.Item("Text1").DataField = rs.Fields("Emp_file").Name
'End With
DataReport2.Sections("section1").Controls
Set DataReport2.DataSource = rs
DataReport2.Show
End Sub

firoz.raj
Posting Pro in Training
415 posts since Dec 2008
Reputation Points: 7
Solved Threads: 1
 

Private Sub Command4_Click()
Set rs = New adodb.Recordset
rs.Open " select * from MR query", con, adOpenDynamic, adLockOptimistic
if rs.recordcount > 0 then
if not rs.eof then
with datareport2.sections("section1").controls
.item("text1").datafield = rs.fields("emp_file").name
'etc.
end with
end if
set datareport2.datasource = rs
datareport2.show
end if

end sub

regards
Ryan Riel

ryan311
Posting Whiz in Training
254 posts since Jul 2008
Reputation Points: 3
Solved Threads: 5
 

[QUOTE=ryan311;769960]Private Sub Command4_Click()
system hangs i don't know why
Private Sub Command4_Click()
Set rs = New adodb.Recordset
rs.Open " select * from MR query", con, adOpenDynamic, adLockOptimistic
If rs.RecordCount > 0 Then
If Not rs.EOF Then
With DataReport2.Sections("section1").Controls
.Item("text1").DataField = rs.Fields("dept_name").Name
End With
Set DataReport2.DataSource = rs
DataReport2.Orientation = rptOrientLandscape
DataReport2.Show
End If
End If
End Sub

firoz.raj
Posting Pro in Training
415 posts since Dec 2008
Reputation Points: 7
Solved Threads: 1
 

Private Sub Command4_Click()
Set rs = New adodb.Recordset
rs.Open " select * from MR query", con, adOpenKeyset, adLockPessimistic
If rs.RecordCount > 0 Then
If Not rs.EOF Then
With DataReport2.Sections("section1").Controls
.Item("text1").DataField = rs.Fields("dept_name").Name
End With
Set DataReport2.DataSource = rs
DataReport2.Show
End If
End If
End Sub


try to erase this

DataReport2.Orientation = rptOrientLandscape

and change this adOpenDynamic, adLockOptimistic
to this adOpenKeyset, adLockPessimistic

regards
Ryan Riel

ryan311
Posting Whiz in Training
254 posts since Jul 2008
Reputation Points: 3
Solved Threads: 5
 

now it is working but requirement is that when user click on print
inputbox should come to demand MR NO if it match with mr_no of database then corresponding record should come in a report
kindly help me
Private Sub Command4_Click()
Set rs = New adodb.Recordset
rs.Open " select * from MR query", con, adOpenDynamic, adLockOptimistic
If Not rs.EOF Then
With DataReport2.Sections("section1").Controls
.Item("text1").DataField = rs.Fields("dept_name").Name
.Item("text2").DataField = rs.Fields("job_no").Name
End With
Set DataReport2.DataSource = rs
DataReport2.Orientation = rptOrientLandscape
DataReport2.Show
End If
End Sub

firoz.raj
Posting Pro in Training
415 posts since Dec 2008
Reputation Points: 7
Solved Threads: 1
 

try to put a where in rs.open select * from mr query where mr no = mr_no

regards
Ryan Riel

ryan311
Posting Whiz in Training
254 posts since Jul 2008
Reputation Points: 3
Solved Threads: 5
 

please mark it solved, if the thread is solved thanks :)

ryan311
Posting Whiz in Training
254 posts since Jul 2008
Reputation Points: 3
Solved Threads: 5
 

i have tried but it is not working kindly let me know
Private Sub Command4_Click()
Dim mr As Integer
mr = InputBox("enter a mr no")
Set rs = New adodb.Recordset
rs.Open " select * from MR query where mr = mr_no", con, adOpenDynamic, adLockOptimistic
If Not rs.EOF Then
With DataReport2.Sections("section1").Controls
.Item("text1").DataField = rs.Fields("dept_name").Name
.Item("text2").DataField = rs.Fields("job_no").Name
End With
Set DataReport2.DataSource = rs
DataReport2.Orientation = rptOrientLandscape
DataReport2.Show
End If
End Sub

firoz.raj
Posting Pro in Training
415 posts since Dec 2008
Reputation Points: 7
Solved Threads: 1
 

Dim mr As Integer
mr = InputBox("enter a mr no:", "Find", "")
Set rs = New adodb.Recordset
rs.CursorLocation = adUseClient
rs.Open " select * from MR query where mr_no = mr", con, adOpenDynamic, adLockOptimistic
If Not rs.EOF Then
With DataReport2.Sections("section1").Controls
.Item("text1").DataField = rs.Fields("dept_name").Name
.Item("text2").DataField = rs.Fields("job_no").Name
End With
Set DataReport2.DataSource = rs
DataReport2.Orientation = rptOrientLandscape
DataReport2.Show
End If

ryan311
Posting Whiz in Training
254 posts since Jul 2008
Reputation Points: 3
Solved Threads: 5
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You