Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

delete database record after printing report data

Status
Not open for further replies.

obulldog27

Programmer
Apr 26, 2004
169
0
0
US
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 reports based
on the inputted data.

What I have to do get this to work is add the records
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
 
Before ...
Code:
Adodc2.Recordset.AddNew

... make sure the recordset is open ...

Code:
Adodc2.Recordset.Open

Patrick
 
One reason why it will give you an error because the delete statement is wrong

SQL = "DELETE * from finalgasbill"

should be SQL = "DELETE from finalgasbill"
without the *
 
Ok now it says operation now allowed when object is OPEN
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top