Results 1 to 8 of 8
  1. #1
    Star Lounger
    Join Date
    Nov 2002
    Posts
    91
    Thanks
    0
    Thanked 0 Times in 0 Posts

    append query (2002)

    Hi all, why when i run an append query directly it works fine, but when i try to run the same append query from within a form (a command button which runs either a macro or expression....tried both) it won't work. The really annoying thing is that if i close the form then re-open and re-run the macro for example .... presto..it works! ugh! any help on this would be greatly appreciated. thanks, Van

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: append query (2002)

    We need a bit more info to be helpful. What doesn't work - do you get an error message, or nothing happens, or what? Also when you say a macro, do you truly mean a macro, or are you executing this in VBA with the click of a button or some other event? We do this sort of thing routinely, so it should work for you.
    Wendell

  3. #3
    Star Lounger
    Join Date
    Nov 2002
    Posts
    91
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: append query (2002)

    Hi WendellB, i've tried both methods.....a macro and code....both with same results. first time i get messages regarding "you are about to append... ", etc. the append query runs but doesn't add the appended records to the table (this table is linked to the backend of the dB). if i then run the macro again (both times it's run using a command button), the messages come up again, same as before, ....and presto....the new records are added to the table w/o problems. Van

  4. #4
    Star Lounger
    Join Date
    Nov 2002
    Posts
    91
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: append query (2002)

    ....one other thing that may be helpful WendellB....I think the problem lies with a key violation (even though both tables are identical). I'm getting a message that, in part, says "...it didn't add 32 records to the table due to key violations,....". However, as i said, if i run the append query directly, it always works and runs fine.

  5. #5
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: append query (2002)

    That's usually a symptom of append queries where there is a problem with the data your are trying to append. It may mean you are trying to fill in an autonumber field, or a field that requires data isn't being populated, or you really are trying to create duplicates. Is your append query stored in code, or are you trying to run a stored query? If it's the former, then check your SQL string very carefully - if it's the latter, then you really do have a mystery.
    Wendell

  6. #6
    Star Lounger
    Join Date
    Nov 2002
    Posts
    91
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: append query (2002)

    i think i've found the problem (but i don't know exactly how to fix it yet). it seems when i click on the command button on the form, the record selector bar turns to a little pencil icon (in grey)....and append query doesn't work. If however, i first click on the record selector (so now the pencil icon is not there, but rather the drk blk arrow), then append query works! why is this? thanks.

  7. #7
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: append query (2002)

    This suggests that the append query depends on the data on the form being saved before it can run.

    You can force this to happen by putting in the line:

    docmd.runcommand acCmdSaveRecord

    before you try to run the append query.
    Regards
    John



  8. #8
    Star Lounger
    Join Date
    Nov 2002
    Posts
    91
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: append query (2002)

    yes, that's it! works fine now. thanks for great help. <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

Posting Permissions

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