Hi, I'm very new to VBA and have been thrown in the deep end a little.
I've had a request that we export our stock list and provide them to a 3rd party on a daily basis.
I've written and tested the basic query and so on but now I need to fine tune it.
I have created a module that will save a text file output:
'------------------------------------------------------------
' StockExport
'
'------------------------------------------------------------
Function StockExport()
On Error GoTo StockExport_Err
' Export Stock Query
DoCmd.TransferText acExportDelim, "StockExportSpec", "qryStockLoc4", "E:\Snow Valley\StockExport.txt", True, ""
StockExport_Exit:
Exit Function
StockExport_Err:
MsgBox Error$
Resume StockExport_Exit
End Function
However, I'd now like to add the date to the end of the filename so I have done:
'------------------------------------------------------------
' StockExport2
'
'------------------------------------------------------------
Function StockExport2()
On Error GoTo StockExport2_Err
' Export Stock Query
Dim txtLocation As
Set txtLocation = "E:\Snow Valley\" & Now() & ".txt"
DoCmd.TransferText acExportDelim, "StockExportSpec", "qryStockLoc4", txtLocation, True, ""
StockExport2_Exit:
Exit Function
StockExport2_Err:
MsgBox Error$
Resume StockExport2_Exit
End Function
My problem is I don't know what to Dim txtLocation As....
What would it be? An object or a data type? Nothing seemed obvious.
I'm also reading up on this so will post if I find the answer.
Many thanks
I've had a request that we export our stock list and provide them to a 3rd party on a daily basis.
I've written and tested the basic query and so on but now I need to fine tune it.
I have created a module that will save a text file output:
'------------------------------------------------------------
' StockExport
'
'------------------------------------------------------------
Function StockExport()
On Error GoTo StockExport_Err
' Export Stock Query
DoCmd.TransferText acExportDelim, "StockExportSpec", "qryStockLoc4", "E:\Snow Valley\StockExport.txt", True, ""
StockExport_Exit:
Exit Function
StockExport_Err:
MsgBox Error$
Resume StockExport_Exit
End Function
However, I'd now like to add the date to the end of the filename so I have done:
'------------------------------------------------------------
' StockExport2
'
'------------------------------------------------------------
Function StockExport2()
On Error GoTo StockExport2_Err
' Export Stock Query
Dim txtLocation As
Set txtLocation = "E:\Snow Valley\" & Now() & ".txt"
DoCmd.TransferText acExportDelim, "StockExportSpec", "qryStockLoc4", txtLocation, True, ""
StockExport2_Exit:
Exit Function
StockExport2_Err:
MsgBox Error$
Resume StockExport2_Exit
End Function
My problem is I don't know what to Dim txtLocation As....
What would it be? An object or a data type? Nothing seemed obvious.
I'm also reading up on this so will post if I find the answer.
Many thanks