|
-
Jun 9th, 2004, 02:36 PM
#1
Thread Starter
Junior Member
Updating Problem
Hey all, I've been workin on this all afternoon and I can't get it working for the life of me. I have tried it too many ways to count so I will post the few where I think I am the closest. I am simply trying to update a record (in access database) using my visual basic form. Here is the code and associated errors:
Connection
Set Rs = New ADODB.Recordset
Rs.Open "Update T_Questions_Static Set IM_Number = " & txtIM & " AND Meeting_Number = " & txtMeeting & " AND Questions_Static = " & txtStatic & "", Cn, adOpenDynamic, adLockBatchOptimistic, cmdAddText
Rs.AddNew
Rs("Meeting_Number") = txtMeeting.Text
Rs("IM_Number") = txtIM.Text
Rs("Questions_Static") = txtStatic.Text
Rs.Update
Rs.UpdateBatch
Rs.MoveNext
Rs.Close
Set Rs = Nothing
Error: No value given for one or more required parameters
Next Try:
Dim Cm As ADODB.Command
Dim Rs As ADODB.Recordset
Set Cm = New ADODB.Command
With Cm
.CommandType = adCmdText
.ActiveConnection = Cn
.CommandText = "Select * From T_Questions_Static"
End With
'Create record set
Set Rs = New ADODB.Recordset
Rs.Open Cm, , adOpenStatic, adLockOptimistic
'Update values for row 1
Rs.AddNew
Rs!Meeting_Number = txtMeeting
Rs!IM_Number = txtIM
Rs!Questions_Static = txtStatic
Call Rs.Update
Set Rs = Nothing
Set adoCommand = Nothing
Exit Sub
Error: THe changes you requested to the table were not successful becayse they would create duplicate values in the index, primary key, etc....
'Updates to T_Questions_Static Table
Connection
Set Rs = New ADODB.Recordset
Rs.Open "Select * From T_Questions_Static", Cn, 1, 3, AddcmdText
With DeMeeting.rsQuestions_Static
Rs("Meeting_Number") = txtMeeting.Text
Rs("IM_Number") = txtIM.Text
Rs("Questions_Static") = txtStatic.Text
DeMeeting.rsQuestions_Static.Update
End With
Set Rs = Nothing
This method kind of works, but it updates the first record in the record set, not the record that it is suppose to update.
Any help is welcome, or suggestions to try something else would also be great. I was thinking it might possibly be the settings in my database that are causing the errors, but I am not sure.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|