Automate Save As Table

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
 
B

BMaerhofer

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!
 
D

Douglas J. Steele

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
 
B

BMaerhofer

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top