Public Function CreateTables()
On Error GoTo CreateTables_Error
Dim db As DAO.Database
Set db = CurrentDb
Dim myTable As DAO.TableDef
Dim myField As DAO.Field
Dim MyTableName As String
Dim MyConnection As String
MyConnection = DLookup("[DataBase]", "MSysObjects", "[DataBase] Is Not Null") 'Backend location
MyTableName = "TblTest" 'Table Name between quotes
Set myTable = db.CreateTableDef(MyTableName)
With myTable
.Fields.Append .CreateField("Test", dbText) 'Field Name between quotes
End With
db.TableDefs.Append myTable
'If split database. Append to backend
If DCount("[DataBase]", "MSysObjects", "[DataBase] Is Not Null") > 0 Then
DoCmd.TransferDatabase acExport, "Microsoft Access", MyConnection, acTable, myTable.Name, myTable.Name
DoCmd.DeleteObject acTable, myTable.Name
DoCmd.TransferDatabase acLink, "Microsoft Access", MyConnection, acTable, myTable.Name, myTable.Name
End If
Set myField = Nothing
Set myTable = Nothing
Exit Function
CreateTables_Error:
DoCmd.CancelEvent
MsgBox Err.DESCRIPTION
Exit Function
End Function
@LarryE loaded your gun for you. And CJ pointed the gun to your head. But I'm here to talk you off the ledge. NEVER, EVER modify the BE while it is open for users. NEVER!!!! Doc has outlined a professional solution. My procedure is slightly different.So, what is your methodology if you are adding a table or two to an existing db that is already split.
Similar to the above comments, with my apps, this is only ever done when updating to a new version.So, what is your methodology if you are adding a table or two to an existing db that is already split.
Somewhere in the middle.Whew! Stirred the pot again
This is likely a case of me just being inexperienced, literally ignorant, of the functionality in Access I'm looking for.
Some clarifications:
1. This question is within the purview of working on development versions of the FE and BE.
2. The only reason this is an issue is because I'm not skilled enough to create a brand new table(s) for new functionality without needing to tweak it at some point possibly.
So, I slimmed down my current app to the basic structure of things to get everything up and running (user management, admin management, deployment, etc) plus a basic actual business process that we need to implement. Then, over time I will add further "modules" to the database to expand its functionality. Some of this functionality will involve many tables, queries and forms and their interactions and will likely be revised often due to my ignorance.
I envisioned working on these modules with the new tables residing (temporarily) in the front end as everything is developed and then when they appear suitable, "pushing" them to the development back end and continuing in development.
So, either there are a few ways everyone is doing this, or, this a totally stupid idea and I need to repent in dust and ashes![]()
It's becoming quite clear that this is not something anyone other than me is worrying about or needs to do!So I was looking for a solution to allow these table changes (due to my dumbness) without needing to constantly close the devFE, open the devBE, make changes, close devBE, open devFE and continue.
Providing you don't have forms open in the FE linked to the BE (or other method maintaining a persistent connection) you can open the (development) BE without closing the FE. If you were to create the table in the FE with the intention of copying across to the BE - look at using the export feature, then the linked table manager.So I was looking for a solution to allow these table changes (due to my dumbness) without needing to constantly close the devFE, open the devBE, make changes, close devBE, open devFE and continue.
Carpenters (not doubt others) have expression - 'measure twice, cut once'. Perhaps spend a bit more time thinking about what you need to do - sketch it out on paper, draw a diagram, whatever before starting to actually create or modify your tables.I'm beginning to see this is a me problem. I change my mind, my ideas are dumb, don't normalize properly, etc.
Thanks for clarifying. However, I think you may be overcomplicating even that. There is probably little reason to keep closing and reopening the back end like that.Somewhere in here we seem to be having a bit of a disconnect.
I am NOT asking how to handle deploying a development database through testing and release to the production environment. I've read in this thread and others some very fine examples of this process from @The_Doc_Man, @Pat Hartman and others. But, again, to be clear. This is NOT what I'm asking about.
My question is narrowly focused on the idea in this quote of myself:
It's becoming quite clear that this is not something anyone other than me is worrying about or needs to do!
This is only an efficiency question as it is quite doable to perform the database close/open dance whenever needed. I just mistakenly thought there might be a better way. I apologize for the confusion.
In this original post, there was not attempt to put the question into context. That appeared only in post #14. In other words, the way the original question was posed was confusing.There are some older posts that imply that functionality MIGHT exist.