Good morning. I'm new to Access VBA (OK with XL!).
Basically I want to add a new field to the end of a table so I can save the records with a unique reference, e.g. "24062011", append these new records to a 'Master' table each time. Good news, I appear to be able to create a new field:-
I appear to be able to prompt & get a value for the date:-
I have tried various combinations (having previously declared & Set:-
)
Do I need to do some sort loop to add this value to all the records in the new field instead?
This doesn't work:-
Many thanks,
Des.
Basically I want to add a new field to the end of a table so I can save the records with a unique reference, e.g. "24062011", append these new records to a 'Master' table each time. Good news, I appear to be able to create a new field:-
Code:
Dim CDbTD As TableDef
Set CDbTD = CurrentDb.TableDefs
CDbTD("Combined_Table").Fields.Append CDbTD("Combined_Table").CreateField("TableDate", dbText, 8)
I appear to be able to prompt & get a value for the date:-
Code:
'Prompt for date
DateString = InputBox("Enter data - Format: ddmmyyyy")
If Len(DateString) > 0 Then
THIS IS WHERE I AM STUCK
End If
I have tried various combinations (having previously declared & Set:-
Code:
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("Combined_Table")
Code:
rs.AddNew
rs("TableDate").DefaultValue = DateString
[Or this:-] rs("TableDate").Value = DateString
("Invalid operation, error 3219")
rs.Update
Do I need to do some sort loop to add this value to all the records in the new field instead?
This doesn't work:-
Code:
For Each x In rs("TableDate")
x = DateString
Next x
Many thanks,
Des.