T
Tiggster
Hello everyone,
I am trying to write a new record to a database table within my current
Access 2003 project and am receiving an error message saying the "operation
not allowed in this context." I am using the following code within my event
handler:
Private Sub cmdAdd_Click()
Dim conn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Set conn = CurrentProject.Connection
rst.Open "tblAccommodations", conn, adOpenKeyset, adLockOptimistic
rst.AddNew
rst.Fields(1).Value = "Steve"
rst.Fields(2).Value = "My description"
rst.Close
Set rst = Nothing
Set conn = Nothing
End Sub
Is this action really not permitted or am I doing something wrong? I'm an
experienced VB.NET and ASP.NET developer, but am unfamiliar with VBScript, so
I'm a little lost here. Is there a better approach to accomplish the same
task?
Thanks for any help or suggestions.
Steve
I am trying to write a new record to a database table within my current
Access 2003 project and am receiving an error message saying the "operation
not allowed in this context." I am using the following code within my event
handler:
Private Sub cmdAdd_Click()
Dim conn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Set conn = CurrentProject.Connection
rst.Open "tblAccommodations", conn, adOpenKeyset, adLockOptimistic
rst.AddNew
rst.Fields(1).Value = "Steve"
rst.Fields(2).Value = "My description"
rst.Close
Set rst = Nothing
Set conn = Nothing
End Sub
Is this action really not permitted or am I doing something wrong? I'm an
experienced VB.NET and ASP.NET developer, but am unfamiliar with VBScript, so
I'm a little lost here. Is there a better approach to accomplish the same
task?
Thanks for any help or suggestions.
Steve