|
-
Sep 15th, 2005, 05:13 PM
#1
Thread Starter
Lively Member
How to update a field??
I have a program that browses an Access 2000 table with an ADO connection in VB 6. I want to add functionality so the user can click on a row to pop open an editing form, and then I want to update the table with their changes after I validate them.
I have the editing form opening just fine.
Can you tell me what I need to do to update the fields in the database table, without screwing other rows up? Failsafe, time-tested method preferred.
Even more helpful, can you suggest a book or other hopefully concise reference I can use to learn all about VB ADO database programming?
Thanks - Tom
-
Sep 15th, 2005, 08:02 PM
#2
Re: How to update a field??
You could use an Action Query like
VB Code:
UPDATE Table SET FieldName='data' WHERE FieldName='Criteria'
-
Sep 16th, 2005, 08:29 AM
#3
Hyperactive Member
Re: How to update a field??
 Originally Posted by dee-u
You could use an Action Query like
VB Code:
UPDATE Table SET FieldName='data' WHERE FieldName='Criteria'
For this to be failsafe though you need a primary key in the table. Say it is a field called ID, and you have two visible text boxes, txtOne and TxtTwo for displaying/editing the fields FieldOne and FieldTwo and one other (locked and probably invisible) called txtID for displaying the ID field. You could then use:
ADOConnection.Execute("UPDATE YourTable SET FieldOne = '" & txtOne & "', FieldTwo = '" & txtTwo & "' WHERE ID = " & txtID)
This is assuming that the two editable fields are text fields and the ID is numeric (autonumber is the easiest).
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
|