Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old August 25th, 2004, 12:18 PM
Frost Frost is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 446 Frost User rank is Corporal (100 - 500 Reputation Level)Frost User rank is Corporal (100 - 500 Reputation Level)Frost User rank is Corporal (100 - 500 Reputation Level)Frost User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 3 Days 16 m 44 sec
Reputation Power: 7
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?

Reply With Quote
  #2  
Old August 25th, 2004, 07:38 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 21 h 32 m 23 sec
Reputation Power: 180
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

Reply With Quote
  #3  
Old August 26th, 2004, 01:03 PM
Frost Frost is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 446 Frost User rank is Corporal (100 - 500 Reputation Level)Frost User rank is Corporal (100 - 500 Reputation Level)Frost User rank is Corporal (100 - 500 Reputation Level)Frost User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 3 Days 16 m 44 sec
Reputation Power: 7
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.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Update Record


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway