|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Update Record
I've got a textbox that a user enters a value in. They then click on a cmd button which updates a table with a value they entered. At least that's what I'd like it to do.
I haven't got the record to update, and it needs to be compared with other ID value in the database to make sure it updates the correct record in the database. This is the varable that is past to track which record to update: IdRecordValue = UserForm1.TextBox1.Value Then based on that variable the database is queried to get the corresponding ROADID and shows it in another textbox: Set dbRst = dbConn.Execute("SELECT ROADID FROM MSLINK_ROADID WHERE MSLINK" & " = " & IdRecordValue) 'Go through the results found. Should only be one as value is unique Dim RoadIdTxtBox As String While Not dbRst.EOF For Each dbField In dbRst.Fields 'MsgBox ("RoadID:" & dbField.Value) UserForm1.TextBox2.Value = dbField.Value Next dbRst.MoveNext Wend RoadIdTxtBox = UserForm1.TextBox2.Value From here the user (if roadIdTxtBox is blank) enters a number and updates the database. This is the part I don't know about. It's in another function a cmbbutton. But I don't know how to make sure the correct row is updated (value from textbox1) and have that row update the column ROADID with the number entered in textbox2 Dim dbRst2 As New ADODB.Recordset dbRst2.Open "MSLINK_ROADID", dbConn, adOpenKeyset, adLockOptimistic, adCmdTable dbRst!RoadID = UserForm1.TextBox2.Value dbRst.Update Updating the database records should be the easy part. Any ideas? |
|
#2
|
|||
|
|||
|
update on a recordset should update any rows which contain changed values.
__________________
====== Doug G ====== I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain |
|
#3
|
|||
|
|||
|
I can't get the record to update at all. It does pass the updated value to the database. I'm not sure if it's because the object I'm passing is a string value and the database column is an integer, or if it's the rst update command itself. It seems to work when I use
dbrst. addnew But I don't want to add a new row, just update an exisiting record. |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > Update Record |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|