I want to start off saying that I am still a beginner at access so forgive me if I use wrong terms or don't really clarify what I am talking about.
I have a form where we create new facilities; once the new facility information is entered, the VBA command will check the "FacilityName" if there is something there then it will do the following;
This code will take template tables and create a copy of the table and put it in the backend; however the names remain as "tbl" and "tblNew", so I added the "DoCmd.Rename" and it still doesn't change the name of the tables. I am looking for this to be generic so we can keep creating more facilities.
Maybe I need a database refresh command because I notice the tables don't show up until I close and reopen the backend.
I have a form where we create new facilities; once the new facility information is entered, the VBA command will check the "FacilityName" if there is something there then it will do the following;
Code:
DoCmd.RunCommand acCmdSaveRecord
If Not IsNull(Me.FacilityName) Then
Forms!frmFacilityMainEntry.Refresh
Forms!frmFacilityMainEntry.Requery
New_Facility = Me!FacilityName
Dim objAcc As Object
Set objAcc = New Access.Application
objAcc.OpenCurrentDatabase ("\\Wrenlab01\administration\DATABASE\RESEARCH DATABASE\MULTIPLE MYELOMA DATABASE\MultipleMyelomaWrenLIS- BackEnd.accdb")
objAcc.DoCmd.CopyObject "\\Wrenlab01\administration\DATABASE\RESEARCH DATABASE\MULTIPLE MYELOMA DATABASE\MultipleMyelomaWrenLIS- BackEnd.accdb", "tbl", acTable, "tblNewFacility"
objAcc.DoCmd.CopyObject "\\Wrenlab01\administration\DATABASE\RESEARCH DATABASE\MULTIPLE MYELOMA DATABASE\MultipleMyelomaWrenLIS- BackEnd.accdb", "tblNew", acTable, "tblNewFacilityPatient"
objAcc.DoCmd.TransferDatabase acImport, "Microsoft Access", "\\Wrenlab01\administration\DATABASE\RESEARCH DATABASE\MULTIPLE MYELOMA DATABASE\MultipleMyelomaWrenLIS.accdb", acTable, "tbl", "tbl", Yes
objAcc.DoCmd.TransferDatabase acImport, "Microsoft Access", "\\Wrenlab01\administration\DATABASE\RESEARCH DATABASE\MULTIPLE MYELOMA DATABASE\MultipleMyelomaWrenLIS.accdb", acTable, "tbl", "tblNew", Yes
objAcc.DoCmd.Rename "tbl" & New_Facility, acTable, "tbl"
objAcc.DoCmd.Rename "tblNew" & New_Facility, acTable, "tblNew"
objAcc.CloseCurrentDatabase
Set objAcc = Nothing
DoCmd.Rename "tbl" & New_Facility, acTable, "tbl"
DoCmd.Rename "tblNew" & New_Facility, acTable, "tblNew"
End If
DoCmd.Close acForm, "frmFacilityMainEntry"
Maybe I need a database refresh command because I notice the tables don't show up until I close and reopen the backend.