Results 1 to 3 of 3

Thread: How to update a field??

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2005
    Location
    Florida
    Posts
    107

    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

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: How to update a field??

    You could use an Action Query like

    VB Code:
    1. UPDATE Table SET FieldName='data' WHERE FieldName='Criteria'
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3
    Hyperactive Member
    Join Date
    May 2005
    Posts
    324

    Re: How to update a field??

    Quote Originally Posted by dee-u
    You could use an Action Query like

    VB Code:
    1. 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
  •  



Click Here to Expand Forum to Full Width