John.Woody
Registered User.
- Local time
- Today, 09:27
- Joined
- Sep 10, 2001
- Messages
- 354
I have a problem with the code below. The sql statements work fine, the line giving me the problem is
Reports!R_RevenueByOp.RecordSource = strSQL
When I open the db and run the code it works perfectly. When I run the code for a 2nd time it crashes the db. It exits in less than 1/2 a second and does not close the .ldb lock file. Any ideas why?
Private Sub Preview_Click()
Dim strSQL As String
If Me.ReportChoice = 1 Then
If IsNull(Me.OperatorID) Then
MsgBox "You must select an operator before you continue.", vbOKOnly + vbExclamation, "Required Entry"
Exit Sub
End If
If IsNull(Me.ShowTop) Or Me.ShowTop = "" Then
strSQL = ...
Else
strSQL = ...
End If
DoCmd.Echo False
DoCmd.OpenReport "R_RevenueByOp", acViewDesign
Reports!R_RevenueByOp.RecordSource = strSQL
DoCmd.Close acReport, "R_RevenueByOp", acSaveYes
DoCmd.Echo True
Reports!R_RevenueByOp.RecordSource = strSQL
When I open the db and run the code it works perfectly. When I run the code for a 2nd time it crashes the db. It exits in less than 1/2 a second and does not close the .ldb lock file. Any ideas why?
Private Sub Preview_Click()
Dim strSQL As String
If Me.ReportChoice = 1 Then
If IsNull(Me.OperatorID) Then
MsgBox "You must select an operator before you continue.", vbOKOnly + vbExclamation, "Required Entry"
Exit Sub
End If
If IsNull(Me.ShowTop) Or Me.ShowTop = "" Then
strSQL = ...
Else
strSQL = ...
End If
DoCmd.Echo False
DoCmd.OpenReport "R_RevenueByOp", acViewDesign
Reports!R_RevenueByOp.RecordSource = strSQL
DoCmd.Close acReport, "R_RevenueByOp", acSaveYes
DoCmd.Echo True