|
-
Aug 7th, 2002, 08:55 PM
#1
Thread Starter
New Member
Data report refresh problem
Hi.
I have been fighting with this for a week or so and tried all sorts of things - including info in old threads on this forum - but can't get it working.
I have a form that contains customer information and numerical fields including calculated results. These are connected to an mdb database through an ado control. Then I have a Data Report to allow the results of the calculation to be printed off for the customer. I have tried linking this report through both a DataEnvironment and ADO code.
The problem is that the report displays the correct data first time. Then if I close the report, change a field in the form and re-calculate the results, then hit the print button again it still shows the old data. If I then close the report, then hit the print button again, it shows the right info. I don't actually have to close the form, just the report.
Below is the code I have in the print button. It is currently set to run from the coded ADO object rather than the DataEnvironment.
Any help will be greatly appreciated.
Thanks
Private Sub cmdPrint_Click()
Dim dblCust As Double
Dim strPadd As String
Dim dteDate As Date
adoResultsold.Recordset.Update
dblCust = txtcustnum(0).Text
strPadd = txtPaddockID(7).Text
dteDate = txtDate(10).Text
With cnnReport
If cnnReport.State = 0 Then
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=D:\Sap Nitrate Program\sap.mdb"
.Open
End If
End With
With cmdReport
.ActiveConnection = cnnReport
.CommandType = adCmdText
.CommandText = "SELECT * FROM customer, results, " & _
"comment WHERE results.custnum = customer.custnum and customer.custnum = " & _
"" & dblCust & " AND results.paddockid = '" & strPadd & "' " & _
"AND comment.id = results.commentid"
End With
Set rstReport = cmdReport.Execute
Set drptResults1.DataSource = Nothing
drptResults1.DataMember = ""
cmdReport.Execute
rstReport.Requery
Set drptResults1.DataSource = rstReport
If rstReport.RecordCount <> 0 Then
drptResults1.Refresh
drptResults1.Show
Else
MsgBox "No Data"
End If
rstReport.Close
cnnReport.Close
End Sub
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
|