VincilLabs
Registered User.
- Local time
- Today, 12:18
- Joined
- May 11, 2011
- Messages
- 13
:banghead:
I'm coding on a locally stored db. I have a code snippet that's locking my database, but it should not be.
Code: --Gets field names from the selected table to put into comboboxes on my form.
The code does its job, but when I try to write more code and save it I get this message:
"Microsoft Access can't save design changes or save a new database object because another user has the file open. To save your design changes or to save to a new object, you must have exclusive access to the file."
To be clear - this is a local database and only I have it open.
This error only happens after the above code executes and I try to save any changes to the database.
Been working on this for a couple hours - I have to run the code, test, close the db and open the db every time I change the value in that combo.
:banghead:
I'm coding on a locally stored db. I have a code snippet that's locking my database, but it should not be.
Code: --Gets field names from the selected table to put into comboboxes on my form.
Code:
Dim masterTable As DAO.TableDef, thisDatabase As DAO.Database
Dim fieldList As String, thisField As Field
Dim controlBox As Control
[COLOR=seagreen]'Set thisDatabase to current Database[/COLOR]
Set thisDatabase = CurrentDb
[COLOR=seagreen]'Set masterTable to the table definition of the table name in xTableNameCombo.value[/COLOR]
Set masterTable = thisDatabase.TableDefs("[" & Me.xTableCombo.value & "]")
[COLOR=seagreen]'fieldList will populate the field combo boxes. Here we set a default value.[/COLOR]
fieldList = "Not Selected"
[COLOR=seagreen]'Loop through all of the fields and add the field name to the fieldList variable.[/COLOR]
For Each thisField In masterTable.Fields
fieldList = fieldList & ";" & thisField.name
Next thisField
For Each controlBox In Me.Controls
If (controlBox.name <> "xTableCombo" And Right(controlBox.name, 5) = "Combo") Then
Me.Controls(controlBox.name).RowSourceType = "Value List"
Me.Controls(controlBox.name).RowSource = fieldList
Me.Controls(controlBox.name).value = "Not Selected"
End If
Next controlBox
[COLOR=seagreen]'Cleanup[/COLOR]
thisDatabase.Close
CurrentDb.Close
Set thisDatabase = Nothing
Set masterTable = Nothing
The code does its job, but when I try to write more code and save it I get this message:
"Microsoft Access can't save design changes or save a new database object because another user has the file open. To save your design changes or to save to a new object, you must have exclusive access to the file."
To be clear - this is a local database and only I have it open.
This error only happens after the above code executes and I try to save any changes to the database.
Been working on this for a couple hours - I have to run the code, test, close the db and open the db every time I change the value in that combo.
:banghead: