[RESOLVED] Another Access VBA RS Question
I am getting an invalid operation error on the underlined section of code. I cant understand it im copying straight from a book for this stuff and the book always seems to be wrong.
VB Code:
rs.Open strSQL, cnn, adOpenDynamic, adLockOptimistic, adCmdText
StatetoAdd = Me.lstStateList.ListIndex
With rs
[U].AddNew[/U]!FK_State = StatetoAdd
.Update
.Close
Populate_lstEmpStates
End With
Re: Another Access VBA RS Question
:)
VB Code:
rs.Open strSQL, cnn, adOpenDynamic, adLockOptimistic, adCmdText
StatetoAdd = Me.lstStateList.ListIndex
With rs
.AddNew
.Fields("FK_State").Value = StatetoAdd
.Update
.Close
Populate_lstEmpStates
End With
Re: Another Access VBA RS Question
I still get the error Invalid operation on the .AddNew Line
VB Code:
rs.Open strSQL, cnn, adOpenDynamic, adLockOptimistic, adCmdText
StatetoAdd = Me.lstStateList.ListIndex
With rs
.AddNew
.Fields("FK_State").Value = StatetoAdd
.Update
.Close
Populate_lstEmpStates
End With
Re: Another Access VBA RS Question
I have changes the underlying record sets SQL to a more simlple - select star from employee states which clears the above error but sticks on the .update line with ODBC call failed. any ideas..
Re: Another Access VBA RS Question
Are there other fields in the table which need to be set? (ie: do not allow Null)
If so, you'll need to add more lines like .Fields("FK_State").Value = StatetoAdd
Re: Another Access VBA RS Question
Yes Si that was the problem... Cheers.