DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: update record with out updating a previous record

  1. #1
    Join Date
    Apr 2006

    update record with out updating a previous record

    record 1 is created and saved to the table. for customer A
    4 hours later customer A comes back and another record is created (record 2). before customer A leaves, they remember they did something else and needs record 2 updated.
    now since customer A has beed here 2 times he has 2 records time stamped with the current date but different times. How can you update the record 2 with out updateing record 1?


    Records are saved with customers A's id number and a timestamp that is created by a varible

    the sql string to update the record

    sql = "UPDATE Table1 SET Notes = ' " & txtnotes & " ' WHERE CustID = " & lblCustID & " AND SampleDate =  " & savedate & " "
    ex. currentdate(0) is the date 1/1/1111 currentdate(1) is the time 12:00:00
    savedate = lblCurrentDate(0).Caption & " " & lblCurrentDate(1).Caption
    the savedate is saved to the table as follows --> 4/14/2006 10:25:07

    At this point I get a datatype mismatch error if I drop the time and leave the date it updates the record but also updates any previous record for that day.

  2. #2
    Join Date
    Apr 2006
    i resolved this problem by doing the following
    add a field to your database named recNumber and field type to autonumber

    run a sql query on the table for recNumber
    Dim sqlFindLast as String
    Dim LastRec as Interger
    sqlFindLast = SELECT recNumber FROM Table1 WHERE custID = ; sqlFindLast
    LastRec = rs(0)

    now update the table with

    sqlupdateNotes = "UPDATE Table1 SET Notes = ' " & txtnotes & " ' WHERE CustID = " & lblCustID & " AND recNumber = " & LastRec & " "

    This will update the last record in the table by customer ID

    This works because of the auto number type for the recNumber field.

Similar Threads

  1. update from record in same table
    By JeePee in forum Database
    Replies: 7
    Last Post: 02-18-2005, 02:42 PM
  2. update certain record
    By james in forum VB Classic
    Replies: 2
    Last Post: 07-02-2002, 05:59 AM
  3. NullPointerException when reading text file
    By Andrew McLellan in forum Java
    Replies: 3
    Last Post: 05-09-2001, 05:34 PM
  4. Update DAO Recordset (sqlPassThrough)
    By Julie in forum VB Classic
    Replies: 7
    Last Post: 03-17-2001, 10:12 AM
  5. Replies: 2
    Last Post: 09-14-2000, 04:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center