Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Nov 2001
    Location
    Sydney, Australia, Australia
    Posts
    75
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Newbe question on VBA syntax (2007)

    I'm having trouble getting my head around VB syntax.

    I have a form which is showing data from a single table. I'm trying to run an update query that copies the ID value from the current record into a field in another table. I have a subroutine linked to a command button to do this. This works fine if I am working with a pre-existing record. However, if I create a new record and then try to run the query I get an error.

    I'm guessing that it hasn't saved the automatically created value of the ID field, and that I can solve this problem by using a move(0) statement on the table before running the query. What is the syntax to do this (ie how do I specify the current table as the object for the move)?

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Newbe question on VBA syntax (2007)

    Sounds like you haven't saved the record yet from the form . Add this line of code to your button:

    If Me.Dirty then RunCommand accmdSaveRecord
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  3. #3
    Star Lounger
    Join Date
    Nov 2001
    Location
    Sydney, Australia, Australia
    Posts
    75
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Newbe question on VBA syntax (2007)

    Thanks. That did the trick.

Posting Permissions

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