Results 1 to 4 of 4
  1. #1
    Star Lounger
    Join Date
    Dec 2001
    Location
    Rickmansworth, Hertfordshire, United Kingdom
    Posts
    83
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Access 2003, experienced user but non-programmer.
    I'm designing a macro that runs an append query to add a single record, then a SetValue action that inserts '2011' into a 'year' field (indexed) which is empty in the appended record. The table contains an ID (indexed number) field related to an ID (primary key) in another table. My problem is that the added '2011' is not going into the 'first' record defined in the macro but into the record which is 'first' in terms of the primary key. If I just run the append query the added record is topmost when the table is opened. In other words the data insertion is being driven by the primary key constraint in the related table. How do I overcome this?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Can you set the year in the append query? You wouldn't need a separate setvalue then.

  3. #3
    Star Lounger
    Join Date
    Dec 2001
    Location
    Rickmansworth, Hertfordshire, United Kingdom
    Posts
    83
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Hans,
    I would do just that if I could. How's it done?
    Roger

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Open the append query in design view.
    I assume that there isn't a column yet that adds values to the Year column.
    In the first empty column, enter 2011 in the Field row, and enter Year (or whatever the exact name of the year field is) in the Append To row.
    When the query is executed, whether interactively or from a macro, the Year field will be set to 2011 in the appended record(s).

Posting Permissions

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