On your suggestion i have tried to implement the following
[vba]Sub SetDefaultValue(tablename As String, fieldname As String, fieldvalue As Variant)
Dim db As Database, tdf As TableDef, fld As Field
Dim blnReturn As Boolean
Set db = CurrentDb
Set tdf = db.TableDefs(tablename)
Set fld = tdf.Fields(fieldname)
tdf.Fields(fieldname).DefaultValue = fieldvalue
db.Close
Set db = Nothing
End Sub
[/vba]
As the main sub routine that actually does the work and the following code
[vba]Private Sub SympDur_DblClick(Cancel As Integer)
'Test code for dynamic user default value settings
Dim tbl As String, ctrlname As String
tbl = Me.RecordSource
ctrlname = Screen.ActiveControl.name
DoCmd.Close acForm, "frmMain"
SetDefaultValue tbl, ctrlname, InputBox("Enter your new default value")
DoCmd.OpenForm "frmMain"
End Sub[/vba]
On the control that i want to set the default value for.
The problem i face now is i get the following error
"Run Time Error 3422:"
"cannot modify table structure another user has the table open."
But as you can see from the code i have closed the forms. and there should be no code with the table open... any help would be appreciated as i need to get this done today if at all possible.
The only other method i can think of that might produce the same results would be to have a lookup table that the user would be able to edit and each fields default value would be a select from where statement... however this would take a very long time to implement where as if i can get this code to work on a single control here i can get it to work throughout the whole system in a matter of minutes.