Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2004

    Unanswered: MS Access Help Please

    Im trying to update a row on my database using input from text fields. Ive managed to get the values into variables, but when I try and update the row it either doesnt do what im expecting or has comile errors.

    The code is....

    'create a recordset variable (array)
    Dim unitsdata As Recordset

    'set that array to be a row in the database
    Set unitsdata = CurrentDb.OpenRecordset("Booking")

    'add a new row to the database

    'populate the array with values
    unitsdata!JobNumber = DataValue1 And ActivityCd = DataValue3 And BookingDate = DataValue4 And JobDescription = DataValue6 And HangerId = DataValue7 And ShopId = DataValue8

    'update the row in question

    I had it working last night with one value but I need the whole row updated!
    Can anyone help please?

  2. #2
    Join Date
    Nov 2004


    Just a suggestion. Try:

    'populate the array with values
    unitsdata!JobNumber = DataValue1
    ActivityCd = DataValue3
    BookingDate = DataValue4
    JobDescription = DataValue6
    HangerId = DataValue7
    ShopId = DataValue8

    But I suspect I'm missing something obvious. Try testing each variable for a null value or zero length string before putting it into a field.

  3. #3
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    Hi Nickaz
    you may get a better response on the Access forum in this site
    if you are going to update a record using your method then you first off need to locate the record in the recordset, then apply the changes, then update the record. Your code is trying to add a record
    DerrickM's response is fine, except he hasn't topped &tailed it

    with untsdata 'populate the array with values
    !JobNumber = DataValue1
    !ActivityCd = DataValue3
    !BookingDate = DataValue4
    !JobDescription = DataValue6
    !HangerId = DataValue7
    !ShopId = DataValue8
    unitsdata.Update 'update the row in question
    end with

    you could do the same task with an sql command
    "insert into unitsdata ..........."

    However if these values are coming from a form have you considered using controls which are bound to a data set. Pardon the MS Jargon, but have you investigated using the form wizard and basing it on the unitsdata table?. THis will handle all (well most of) the SQL interface issues involved in inserting, adding and deleting records.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts