Results 1 to 8 of 8
  1. #1
    Join Date
    Jun 2011
    Posts
    26

    Unanswered: openargs linking problem

    Hello all,

    I've been trying all day to figure this out and it's probably something simple. I have a main demographics form which includes people's ID as well as other info about them and a visit form which also has their ID along with other info about their visit. On the main demographic form there is a button that opens up the visit form and transposes the ID that is typed into the demographic form onto the visit form using an openarg. My problem is when entering a new ID on the demographics page and then opening up the visits form using the button, after I enter the rest of the info and close the visit form, I receive an error saying that the engine cannot fine a record in the table demographics with key matching field ID. When I view the tables, all of the data I entered into the demographics form is present, but none of the info from the visit form. What I find strange is that if I delete the transposed ID number from the visit form, and retype the same exact number, it works. I think there may be a timing issue someplace but I'm unsure.

    ID is the primary key and there is a one to many relationship.

    Any insight will help.

  2. #2
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    In the code behind your button to open the second form, immediately before the command to open the second form, add this line and see what happens:

    If Me.Dirty Then Me.Dirty = False

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    Join Date
    Jun 2011
    Posts
    26

    Worked!

    Thank you so much! It worked. With my current limited knowledge and internet searching I would never have done that. What does that command do exactly in this example?

  4. #4
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    The problem you were experiencing was caused because the Current Record on your Main Form, and its ID, hadn't been saved as yet when you clicked on the button to open your Visit Form. Since it hadn't been saved, the Record actually didn't exist, and hence its ID wasn't available to be passed via OpenArgs to the Visit Form.

    If Me.Dirty Then Me.Dirty = False forces the Record to be saved before Access attempts to pass the ID to second Form.

    If Me.Dirty Then

    checks to see if the Record is, indeed, Dirty. Being Dirty means that data entered in a Record hasn't been saved yet.

    If Me.Dirty

    is a shortcut we use, and actually means

    If Me.Dirty = True.

    so

    If Me.Dirty = True Then Me.Dirty = False

    If the Record is Dirty (True) Then we change the Dirty Property to False. If Dirty is now False, the Record has been saved.

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #5
    Join Date
    Jun 2011
    Posts
    26
    Thanks again. You're explanation was extremely clear and will help me in the future.

  6. #6
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    That's why we're here!

    Good luck with your project!

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  7. #7
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    Another option is to run the following command:

    Code:
    docmd. RunCommand acCmdSaveRecord
    But remove the space after the period.

  8. #8
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Quote Originally Posted by DCKunkle View Post
    Another option is to run the following command:

    Code:
    docmd. RunCommand acCmdSaveRecord
    But remove the space after the period.
    I was going to add that, but I hate what the site does when you post DoCmd****nCommand and having to explain it! Wish they could get that fixed!

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Posting Permissions

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