n1a2v3i3n
Programmer
- Jan 19, 2009
- 18
Hi,
I would like to close the database connection when i close the data report. I am using the following to call the data report to show the report.
Private Sub Command5_Click()
Dim st As String
Dim good As String
Dim a As Date, b As Date
good = Chr(35)
a = sdt1
b = edt2
str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Vechdetail.mdb;Persist Security Info=False"
st = " select * from service where dat between " & good & sdt1 & good & "and" & good & edt2 & good & ""
Adodc1.Open st, str, adOpenDynamic, adLockOptimistic
If Adodc1.EOF = True Or Adodc1.BOF = True Then
MsgBox "No Records"
Exit Sub
Else
Do While Not Adodc1.EOF
Adodc1.MoveNext
Loop
End If
Set expdr.DataSource = Adodc1
expdr.Show
End Sub
This code runs for the first time but when i want to run the same for the second time i get and error "Operation is not allowed when the object is open".
Any one could tell me a possible solution for this.
Thanks
I would like to close the database connection when i close the data report. I am using the following to call the data report to show the report.
Private Sub Command5_Click()
Dim st As String
Dim good As String
Dim a As Date, b As Date
good = Chr(35)
a = sdt1
b = edt2
str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Vechdetail.mdb;Persist Security Info=False"
st = " select * from service where dat between " & good & sdt1 & good & "and" & good & edt2 & good & ""
Adodc1.Open st, str, adOpenDynamic, adLockOptimistic
If Adodc1.EOF = True Or Adodc1.BOF = True Then
MsgBox "No Records"
Exit Sub
Else
Do While Not Adodc1.EOF
Adodc1.MoveNext
Loop
End If
Set expdr.DataSource = Adodc1
expdr.Show
End Sub
This code runs for the first time but when i want to run the same for the second time i get and error "Operation is not allowed when the object is open".
Any one could tell me a possible solution for this.
Thanks