T
tamxwell
I need to export the results of a query to Excel (on desktop) The
spreadsheets needs to have some formulas already in place. I am doing Sums on
fields that need to be well, sumed. here is my VB statement.
Thanks Todd
Private Sub Command1_Click()
On Error GoTo Err_Command1_Click
Dim strPath As String
strPath = GetDesktopFolder & "\" & InputBox("What do you want to name the
file?")
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel97,
"qryAdjBadDebt", _
strPath, 1
Exit_Command1_Click:
Exit Sub
Err_Command1_Click:
MsgBox Err.Description
Resume Exit_Command1_Click
End Sub
Function GetDesktopFolder() As String
Dim obj As Object
Set obj = CreateObject("WScript.Shell")
GetDesktopFolder = obj.SpecialFolders("Desktop")
End Function
Private Sub Command2_Click()
On Error GoTo Err_Command2_Click
Dim strPath As String
strPath = GetDesktopFolder & "\" & InputBox("What do you want to name the
file?")
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel97,
"qryAdjBadDebtCustomer", _
strPath, 1
Exit_Command2_Click:
Exit Sub
Err_Command2_Click:
MsgBox Err.Description
Resume Exit_Command2_Click
End Sub
Private Sub cmd6_Click()
On Error GoTo Err_cmd6_Click
Dim stDocName As String
stDocName = "qryAdjBadDebt"
DoCmd.OpenQuery stDocName, acNormal, acEdit
Exit_cmd6_Click:
Exit Sub
Err_cmd6_Click:
MsgBox Err.Description
Resume Exit_cmd6_Click
End Sub
Private Sub cmd7_Click()
On Error GoTo Err_cmd7_Click
Dim stDocName As String
stDocName = "qryAdjBadDebtCustomer"
DoCmd.OpenQuery stDocName, acNormal, acEdit
Exit_cmd7_Click:
Exit Sub
Err_cmd7_Click:
MsgBox Err.Description
Resume Exit_cmd7_Click
End Sub
Private Sub Command28_Click()
On Error GoTo Err_Command28_Click
Dim stDocName As String
stDocName = "qryBadDebtCustomerSub"
DoCmd.OpenQuery stDocName, acNormal, acEdit
Exit_Command28_Click:
Exit Sub
Err_Command28_Click:
MsgBox Err.Description
Resume Exit_Command28_Click
spreadsheets needs to have some formulas already in place. I am doing Sums on
fields that need to be well, sumed. here is my VB statement.
Thanks Todd
Private Sub Command1_Click()
On Error GoTo Err_Command1_Click
Dim strPath As String
strPath = GetDesktopFolder & "\" & InputBox("What do you want to name the
file?")
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel97,
"qryAdjBadDebt", _
strPath, 1
Exit_Command1_Click:
Exit Sub
Err_Command1_Click:
MsgBox Err.Description
Resume Exit_Command1_Click
End Sub
Function GetDesktopFolder() As String
Dim obj As Object
Set obj = CreateObject("WScript.Shell")
GetDesktopFolder = obj.SpecialFolders("Desktop")
End Function
Private Sub Command2_Click()
On Error GoTo Err_Command2_Click
Dim strPath As String
strPath = GetDesktopFolder & "\" & InputBox("What do you want to name the
file?")
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel97,
"qryAdjBadDebtCustomer", _
strPath, 1
Exit_Command2_Click:
Exit Sub
Err_Command2_Click:
MsgBox Err.Description
Resume Exit_Command2_Click
End Sub
Private Sub cmd6_Click()
On Error GoTo Err_cmd6_Click
Dim stDocName As String
stDocName = "qryAdjBadDebt"
DoCmd.OpenQuery stDocName, acNormal, acEdit
Exit_cmd6_Click:
Exit Sub
Err_cmd6_Click:
MsgBox Err.Description
Resume Exit_cmd6_Click
End Sub
Private Sub cmd7_Click()
On Error GoTo Err_cmd7_Click
Dim stDocName As String
stDocName = "qryAdjBadDebtCustomer"
DoCmd.OpenQuery stDocName, acNormal, acEdit
Exit_cmd7_Click:
Exit Sub
Err_cmd7_Click:
MsgBox Err.Description
Resume Exit_cmd7_Click
End Sub
Private Sub Command28_Click()
On Error GoTo Err_Command28_Click
Dim stDocName As String
stDocName = "qryBadDebtCustomerSub"
DoCmd.OpenQuery stDocName, acNormal, acEdit
Exit_Command28_Click:
Exit Sub
Err_Command28_Click:
MsgBox Err.Description
Resume Exit_Command28_Click