Results 1 to 10 of 10
  1. #1
    Lounger
    Join Date
    Dec 2002
    Location
    Rochdale, Gtr Manchester, England
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Saving record in sub forms (access xp)

    I have a form which has a sub form linked to another table in the db. Users enter info in the main form and it is carried across to the sub form. They can then (optionally) go in and change the data in the sub form.
    I am getting reports that sometimes the data in the sub form is not saved - and I cannot work out why. According to the help, any time you close or exit a form any data is automatically saved - and that is the behaviour I am seeing when I test. So, can anyone explain why some data may not be saved and, if so, how I get round it

    My form has a close button which performs a close. It also has the normal 'X' in the top right of the window. Users use both or either.

    many thanks

    Alan

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Saving record in sub forms (access xp)

    The cause I would immediately suspect is operator error. Records will normally be saved in a subform if you move out of the subform or move to a different record. However, if any required fields are not filled in, then the record won't be saved and the user would ordinarily see an error message unless you've suppressed it. Events can also interfere with one another at time. If you used the LostFocus event of the last control to set some required value and the user clicks the close button, the LostFocus event of the control may not occur.

    Without more information on what is actually happening, it isn't possible to guess. I have known users to complain about lost records because the records scrolled off the visible part of the form and the user didn't know that the scrollbar would bring them back into view. More specific information is needed.
    Charlotte

  3. #3
    Lounger
    Join Date
    Dec 2002
    Location
    Rochdale, Gtr Manchester, England
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Saving record in sub forms (access xp)

    Thanks Charlotte. I would also suspect operator error if there weren't over 300 records in the table with missing information (out of about 3,000). I do not have any required fields and I don't use the Lost Focus method anywhere.
    I'll keep investigating. It's going to be something stupid - I just need to find it.

    thanks

    Alan

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Saving record in sub forms (access xp)

    I thought you had said that records were missing. If it's information that should exist within records and doesn't, then it is either operator error or programmer error. If data is being entered but not saved, then I would suspect programmer error and you'll need to review your code carefully, stepping through it to see exactly when things happen and what might be going wrong.
    Charlotte

  5. #5
    Lounger
    Join Date
    Dec 2002
    Location
    Rochdale, Gtr Manchester, England
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Saving record in sub forms (access xp)

    Thanks - but there is no code ! So, I am thinking it is operator error or Access errors. I am in the process of getting SP1 and SP2 put on the affected machines (mine already has them) and am forcing an explicit SAVE in my routines (OK, there is a small amount of code, 5 lines).

    Cheers

    Alan

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Saving record in sub forms (access xp)

    If you can't reproduce the error yourself, you might try to observe one of the users for a while (probably nothing will go wrong then...)

    What is the code behind the Close button on your form?

  7. #7
    New Lounger
    Join Date
    Feb 2003
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Saving record in sub forms (access xp)

    I'm an access rookie but . . . I have set up a shared database for work and what we run into is, if the user gets an error message that says, "Currently locked, can not update" and they don't tell me so I can do a compact and repair, any information added from that point on is lost for everyone. I'm not talking about the error message where more than one person is in a record at a time, this one just says Currently locked...

    Sharing your pain,
    Trese

    Even if this helps, I'm afraid I haven't been much help because my instructor told me that there's nothing that I've done wrong, the system administrator probably has some locks at the AS400 level not at the access database level.

  8. #8
    Lounger
    Join Date
    Dec 2002
    Location
    Rochdale, Gtr Manchester, England
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Saving record in sub forms (access xp)

    This is my code:

    Private Sub Close_form_Click()
    On Error GoTo Err_Close_form_Click


    DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
    DoCmd.close

    Exit_Close_form_Click:
    Exit Sub

    Err_Close_form_Click:
    MsgBox Err.Description
    Resume Exit_Close_form_Click

    End Sub

    Not exactly rocket science ! I have observed and yes, there is no issue !!!!!

    Alan

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Saving record in sub forms (access xp)

    Your code should either save the record, or display an error message if the record can't be saved for some reason. So if data are not being saved without raising an error message, I would suspect the users are making mistakes.

    Minor quibble: the code
    <font face="Georgia">DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70</font face=georgia>
    is an antiquated leftover from AccessBasic (from 3 versions ago or so). For some reason, the Command Button Wizard still generates this kind of code. It can be replaced by the shorter and more readable
    <font face="Georgia">RunCommand acCmdSaveRecord</font face=georgia>

  10. #10
    Lounger
    Join Date
    Dec 2002
    Location
    Rochdale, Gtr Manchester, England
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Saving record in sub forms (access xp)

    As ever - the board got it right.

    After much investigation it is user error. There is one field, 'bar code' which links the two tables. The user was entering data in both forms but not entering a bar code. So, when they came to retrieve the data, the record in the sub form was never found !

    Once again, thanks for your help.

    regards

    Alan

Posting Permissions

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