docmd.rename now working correctly. very strange

bhlgroup

New member
Local time
Today, 17:18
Joined
Dec 7, 2011
Messages
5
I have to rename a table in my code so I can do some comparing. anyway If I run my code manually (or by running a macro that calls the code) everything works as it should. BUT if I call the macro from a batch file the docmd.rename part doesnt run. the rest of the code does.

heres a simple way for you to replicate (either .mdb 2000/2003 or .accdb 2007)

1 x Table - Name: "Old" (content not important)

1 x Macro - Name: "Macro1"
*Macro Content*
RunCode - test()
Quit - SaveAll

1 x Module - Name: "module1"
*Module Content*
Public Function test()
MsgBox "Start"
DoCmd.Rename "New", acTable, "Old"
MsgBox "End"
End Function

now running the code or the macro manually everything works as it should.

however running from a batch file (see batch file below) results in the msgbox appearing so we know it is running the code but the table doesnt get renamed.

Batch File
"C:\Program Files\Microsoft Office\Office12\msaccess.exe" "D:\test\1.accdb" /runtime /nostartup /x Macro1

This is confusing the hell out of me because I see no reason why that particular cmd isnt working.
 
thanks.

this was my finished code in the end:

Dim tdf As TableDef

For Each tdf In CurrentDb.TableDefs
If tdf.Name = "New_NB_Cust" Then
DoCmd.DeleteObject acTable, "Old_NB_Cust"
tdf.Name = "Old_NB_Cust"
End If
Next
 
I am glad to hear you arrived at a solution. Thank you for posting the success followup.
 

Users who are viewing this thread

Back
Top Bottom