C
Cyberwolf
I have a form that has a check box in the form footer called chkTBArchive. I
have a button on the same form footer that runs code that uses this check box
to run or not run specific queries based on its value. When I clikc the
button the code runs up to this point and errors out with a run-time error
2467 "The expression you entered refers to an object that is closed or
doesn't exist.
The strange thing is that I pulled this code from another form that contains
the same coding but the check box is part of the main form and is not on the
form footer.
Any help would be greatly appreciated. see code below
Private Sub butTBOps_Click()
'On Error GoTo Err_butTBOps_Click
Dim stDocName As String
Dim stDocName1 As String
Dim stDocName2 As String
Dim stDocName3 As String
Dim stDocName4 As String
Dim stDocName5 As String
Dim stDocName6 As String
Dim stDocName7 As String
Dim intResponse As Integer
Dim xlApp As New Excel.Application
Dim xlWkb As Excel.Workbook
DoCmd.Close acForm, "frm:Current TB", acSaveNo
DoCmd.RunMacro "macelWalTB"
Set xlApp = New Excel.Application
Set xlWkb = xlApp.Workbooks.Open("G:\Accounting\AR\AR
Database\Macros.xls", 0)
xlApp.Visible = True
xlWkb.Windows(1).Visible = True
xlWkb.Application.Run ("Import_TB")
xlWkb.Close savechanges:=False
Set xlWkb = Nothing
xlApp.Quit
Set xlApp = Nothing
' This Deletes the info in the Old TB Table
stDocName2 = "qryel Old TB"
DoCmd.OpenQuery stDocName2, acViewNormal, acEdit
' This Copies the info From the Current TB to the Old TB
stDocName3 = "qry:Current TB to Old TB"
DoCmd.OpenQuery stDocName3, acNormal, acEdit
' This deletes the info in the Current TB
stDocName4 = "qryel Current TB"
DoCmd.OpenQuery stDocName4, acViewNormal, acEdit
' This Transfers the Delimited text file to the Current TB
DoCmd.TransferText acImportDelim, "kal-wal tb Import Specification",
"Current TB", "\\Pasvr\Group\Accounting\AR\AR Database\kal-wal TB.txt", True
' Copies the Old TB Status Info to the Current TB
stDocName5 = "qry:Update Current TB"
DoCmd.OpenQuery stDocName5, acViewNormal, acEdit
' This will copy the Old TB to the Archive TB if the Check box is checked
If chkTBArchive = True Then
stDocName = "qry:TB Archive"
DoCmd.OpenQuery stDocName, acNormal, acEdit
' This will add the week nunmber to the Archive TB
stDocName1 = "qry:TB Archive Week Update"
DoCmd.OpenQuery stDocName1, acViewNormal, acEdit
End If
'Message to state the Trial balance is loaded
MsgBox "The Current Trial Balance has been loaded.", vbOKOnly, "File
Operation Complete"
'Reopens the Current Trial Balance form
DoCmd.OpenForm "frm:Current TB", acNormal, , , acFormEdit, acWindowNormal
Exit_butTBOps_Click:
Exit Sub
Err_butTBOps_Click:
MsgBox Err.Description
Resume Exit_butTBOps_Click
End Sub
have a button on the same form footer that runs code that uses this check box
to run or not run specific queries based on its value. When I clikc the
button the code runs up to this point and errors out with a run-time error
2467 "The expression you entered refers to an object that is closed or
doesn't exist.
The strange thing is that I pulled this code from another form that contains
the same coding but the check box is part of the main form and is not on the
form footer.
Any help would be greatly appreciated. see code below
Private Sub butTBOps_Click()
'On Error GoTo Err_butTBOps_Click
Dim stDocName As String
Dim stDocName1 As String
Dim stDocName2 As String
Dim stDocName3 As String
Dim stDocName4 As String
Dim stDocName5 As String
Dim stDocName6 As String
Dim stDocName7 As String
Dim intResponse As Integer
Dim xlApp As New Excel.Application
Dim xlWkb As Excel.Workbook
DoCmd.Close acForm, "frm:Current TB", acSaveNo
DoCmd.RunMacro "macelWalTB"
Set xlApp = New Excel.Application
Set xlWkb = xlApp.Workbooks.Open("G:\Accounting\AR\AR
Database\Macros.xls", 0)
xlApp.Visible = True
xlWkb.Windows(1).Visible = True
xlWkb.Application.Run ("Import_TB")
xlWkb.Close savechanges:=False
Set xlWkb = Nothing
xlApp.Quit
Set xlApp = Nothing
' This Deletes the info in the Old TB Table
stDocName2 = "qryel Old TB"
DoCmd.OpenQuery stDocName2, acViewNormal, acEdit
' This Copies the info From the Current TB to the Old TB
stDocName3 = "qry:Current TB to Old TB"
DoCmd.OpenQuery stDocName3, acNormal, acEdit
' This deletes the info in the Current TB
stDocName4 = "qryel Current TB"
DoCmd.OpenQuery stDocName4, acViewNormal, acEdit
' This Transfers the Delimited text file to the Current TB
DoCmd.TransferText acImportDelim, "kal-wal tb Import Specification",
"Current TB", "\\Pasvr\Group\Accounting\AR\AR Database\kal-wal TB.txt", True
' Copies the Old TB Status Info to the Current TB
stDocName5 = "qry:Update Current TB"
DoCmd.OpenQuery stDocName5, acViewNormal, acEdit
' This will copy the Old TB to the Archive TB if the Check box is checked
If chkTBArchive = True Then
stDocName = "qry:TB Archive"
DoCmd.OpenQuery stDocName, acNormal, acEdit
' This will add the week nunmber to the Archive TB
stDocName1 = "qry:TB Archive Week Update"
DoCmd.OpenQuery stDocName1, acViewNormal, acEdit
End If
'Message to state the Trial balance is loaded
MsgBox "The Current Trial Balance has been loaded.", vbOKOnly, "File
Operation Complete"
'Reopens the Current Trial Balance form
DoCmd.OpenForm "frm:Current TB", acNormal, , , acFormEdit, acWindowNormal
Exit_butTBOps_Click:
Exit Sub
Err_butTBOps_Click:
MsgBox Err.Description
Resume Exit_butTBOps_Click
End Sub