delete database record after printing report data

captain27
10-20-2004, 04:50 PM
This is what I want my program to do.

The user inputs data onto a form. About 24 textboxes.
Then their is a print button to view the report based
on the inputted data.

What I have to do get this to work is add the record
via adodc to a ms access database EMPTY table (one table with no relationships) then with dataenvironment put
then on the datareport which is much easier then coding
it. But I only want the record being inputted to print out (one page), therefore after printing the report I delete everything from the database but I get an error.

"Operation is not allowed when the object is closed"
------------------------------------------------------
Private Sub printfg_Click()
Adodc2.Recordset.AddNew
Adodc2.Recordset!Name = namefg.Text
Adodc2.Recordset!beg_meter_reading = begfg.Text
Adodc2.Recordset!end_meter_reading = endfg.TexT
....
....
....
Adodc2.Recordset.Update
Adodc2.Refresh
''''''print report''''
With DataEnvironment1
If .rsbilladj_FGrep.State = 0 Then
.rsbilladj_FGrep.Open
End If
.rsbilladj_FGrep.Requery
End With
BillingStatementFG.Refresh
If Check1.Value = 1 Then
BillingStatementFG.Show
Else
BillingStatementFG.PrintReport
End If

''''delete report'''''''''
SQL = "DELETE * from finalgasbill"
With Adodc2
.RecordSource = SQL
.Refresh
End With
End Sub

couch612
10-25-2004, 07:58 PM
i think the following code is being executed while the report is open, causing the error:


''''delete report'''''''''
SQL = "DELETE * from finalgasbill"
With Adodc2
.RecordSource = SQL
.Refresh
End With


try moving this code so that it is executed after the report object is closed by the user.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum