Automate Save As Table

  • Thread starter Thread starter BMaerhofer
  • Start date Start date
B

BMaerhofer

I am having some trouble trying to automate a table save as.
Currently we import a table everyday and then rename it.

I would like to automate it so we do not have to do that.

Original Name: TC340

Change To: TEST TEST2 XXXXXX YYY EA ORIG

XXXXXX = Date, Prompt to input date
YYY = Record count within table

I would like the only prompt to ask for the date, but automate the record
count and the rest of the standard file name.

Thanks,
Brian
 
SAMPLE:

Sub Rename_TEST()
DoCmd.CopyObject , "TEST TEST2", acTable, "TEST"

End Sub

- What I need is to add date and Record count when it renames the file based
on the date promted to input.
"TEST TEST2 (DATE) (RECORD COUNT) EA ORIG"

Thanks!
 
Your CopyObject syntax is incorrect, so I'm having a hard time figuring out
what's what.

Originally, you said that the table is named TC340. You could try something
like:

Sub Rename_TC340
Dim strDate As String

strDate = InputBox("What date do you want to use?")
If IsDate(strDate) Then
DoCmd.Rename "TEST TEST2 (" & Format(CDate(strDate, "yyyymmdd")) & _
") (" & DCount("*", "TC340") & ") EA ORIG", acTable, "TC340"
Else
MsgBox strDate & " is not a valid date."
End If

End Sub
 
Thanks!

It works.
--
BWM


Douglas J. Steele said:
Your CopyObject syntax is incorrect, so I'm having a hard time figuring out
what's what.

Originally, you said that the table is named TC340. You could try something
like:

Sub Rename_TC340
Dim strDate As String

strDate = InputBox("What date do you want to use?")
If IsDate(strDate) Then
DoCmd.Rename "TEST TEST2 (" & Format(CDate(strDate, "yyyymmdd")) & _
") (" & DCount("*", "TC340") & ") EA ORIG", acTable, "TC340"
Else
MsgBox strDate & " is not a valid date."
End If

End Sub
 
Back
Top