G
George Lee
I’m using ADO for reading and write an Access 2007 database. Writing to most
fields is no problem. Except, for value lists (where only selected values may
be entered). I get an error on that line. How do you write to value
list-defined fields?
Private Sub Command1_Click()
On Error GoTo ErrorHappened
Dim cn As ADODB.Connection
Set cn = New ADODB.Connection
cn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=C:\TrialDatabase.accdb;Persist Security Info=False;"
cn.Open
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
rs.Open "Trial_List", cn, adOpenKeyset, adLockPessimistic, adCmdTable
rs.AddNew
rs.Fields("Title") = "Favorite Foods"
rs.Fields("Cake_Type") = "Cheese cake" 'Value list entry. Error here.
rs.Update
Exit Sub
ErrorHappened:
MsgBox Err.Number
End Sub
fields is no problem. Except, for value lists (where only selected values may
be entered). I get an error on that line. How do you write to value
list-defined fields?
Private Sub Command1_Click()
On Error GoTo ErrorHappened
Dim cn As ADODB.Connection
Set cn = New ADODB.Connection
cn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=C:\TrialDatabase.accdb;Persist Security Info=False;"
cn.Open
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
rs.Open "Trial_List", cn, adOpenKeyset, adLockPessimistic, adCmdTable
rs.AddNew
rs.Fields("Title") = "Favorite Foods"
rs.Fields("Cake_Type") = "Cheese cake" 'Value list entry. Error here.
rs.Update
Exit Sub
ErrorHappened:
MsgBox Err.Number
End Sub