Yesterday "HTH" taught me how to convert a file name in VBA. Thanks HTH!!
The problem I have now is that if the filename already exists, I have to go to that folder and delete it before runing the program. Is there a way in VBA to have it overwrite an existing file rather than giving me the error "file already exists"?
Below is the code I'm using:
Function JaSat_Macro()
On Error GoTo JaSat_Macro_Err
DoCmd.SetWarnings False
DoCmd.OpenQuery "JaSat NEW Q1", acViewNormal, acEdit
DoCmd.OpenQuery "JaSat NEW Q2c", acViewNormal, acEdit
DoCmd.OpenQuery "JaSat NEW Q3", acViewNormal, acEdit
DoCmd.TransferText acExportDelim, "JASAT Export Specification", "JaSat", "[oldfile]", False, ""
Dim OldName, NewName
OldName = "[oldfile]": NewName = "[newfile]
Name "[oldfile]" As "[newfile]"
JaSat_Macro_Exit:
Exit Function
JaSat_Macro_Err:
MsgBox Error$
Resume JaSat_Macro_Exit
End Function
The problem I have now is that if the filename already exists, I have to go to that folder and delete it before runing the program. Is there a way in VBA to have it overwrite an existing file rather than giving me the error "file already exists"?
Below is the code I'm using:
Function JaSat_Macro()
On Error GoTo JaSat_Macro_Err
DoCmd.SetWarnings False
DoCmd.OpenQuery "JaSat NEW Q1", acViewNormal, acEdit
DoCmd.OpenQuery "JaSat NEW Q2c", acViewNormal, acEdit
DoCmd.OpenQuery "JaSat NEW Q3", acViewNormal, acEdit
DoCmd.TransferText acExportDelim, "JASAT Export Specification", "JaSat", "[oldfile]", False, ""
Dim OldName, NewName
OldName = "[oldfile]": NewName = "[newfile]
Name "[oldfile]" As "[newfile]"
JaSat_Macro_Exit:
Exit Function
JaSat_Macro_Err:
MsgBox Error$
Resume JaSat_Macro_Exit
End Function