B
Bonnie
Can anyone help me please. I am opening a form (SelectIn) that has a combo
box that offers me the states from a table. When I select a state, a make
table query is run that pulls all records from that state to a table named
temp. Then I want to copy temp to an XLS named state_sales.xls (state being
the state that I have selected). I am receiving the error "requires an
object name argument". Can anyone tell me what I am doing wrong in this code?
Thanks in advance.
Function ToXLS()
On Error GoTo ToXLS_Err
DoCmd.OpenForm "SelectIn"
DoCmd.SetWarnings False
DoCmd.Close acQuery, GetState
DoCmd.SetWarnings True
DoCmd.OutputTo acTable, "TEMP", "MicrosoftExcelBiff8(*.xls)",
"C:\CARGO\" & [Forms]![SelectIN]![Combo8] & "_SALES.XLS", False, "", 0
Call Copydbfs
ToXLS_Exit:
Exit Function
ToXLS_Err:
MsgBox Error$
Resume ToXLS_Exit
End Function
Public Function Copydbfs()
FileCopy "C:\CARGO\" & [Forms]![SelectIN]![Combo8] & "_Sales.XLS",
"C:\" & [Forms]![SelectIN]![Combo8] & "Sales.XLS"
End Function
box that offers me the states from a table. When I select a state, a make
table query is run that pulls all records from that state to a table named
temp. Then I want to copy temp to an XLS named state_sales.xls (state being
the state that I have selected). I am receiving the error "requires an
object name argument". Can anyone tell me what I am doing wrong in this code?
Thanks in advance.
Function ToXLS()
On Error GoTo ToXLS_Err
DoCmd.OpenForm "SelectIn"
DoCmd.SetWarnings False
DoCmd.Close acQuery, GetState
DoCmd.SetWarnings True
DoCmd.OutputTo acTable, "TEMP", "MicrosoftExcelBiff8(*.xls)",
"C:\CARGO\" & [Forms]![SelectIN]![Combo8] & "_SALES.XLS", False, "", 0
Call Copydbfs
ToXLS_Exit:
Exit Function
ToXLS_Err:
MsgBox Error$
Resume ToXLS_Exit
End Function
Public Function Copydbfs()
FileCopy "C:\CARGO\" & [Forms]![SelectIN]![Combo8] & "_Sales.XLS",
"C:\" & [Forms]![SelectIN]![Combo8] & "Sales.XLS"
End Function