Results 1 to 12 of 12
  1. #1
    Join Date
    Sep 2001
    Posts
    175

    Question Unanswered: Problems with Form/SubForm - Urgent

    In Access 2000 I initially created a form with a subform which was working. However the user now prefers to have a form with a button that calls the subform. I have since split the form and subform but when I enter info in the subform it is not being saved. The info in the form is saved. The only change I made with the initial form/subform is put a button on the form to open the subform.

    Why isn't the info on the subform being saved although I have clicked the save button?

    Urgent help needed

  2. #2
    Join Date
    Feb 2003
    Location
    Auckland, NZ
    Posts
    150
    Open the subform in design view. In the properties eindow of the form, check that the Record Source is Correct(i.e. is linked to a Query or Table.

    If this is correct, open the Main form in design view. Click on the subform and view the properties Paren/child linked fields are correct.
    JJ Kennedy
    Double J IT Solutions
    www.doublejit.co.nz

    VB 6, VB.NET, ASP.NET, MS SQL Server, MySQL, MS Access

  3. #3
    Join Date
    Aug 2002
    Location
    Melbourne, Australia
    Posts
    111
    Are the forms you are using now Main Form and Sub From or Main Form and Linked Form?


    John A
    Regards,



    John A

  4. #4
    Join Date
    Sep 2001
    Posts
    175
    Right now the from are NOT Main Form and Sub Form. They are two separate forms. Maybe I need to link them, if so, how do I go about doing that?

  5. #5
    Join Date
    Aug 2002
    Location
    Melbourne, Australia
    Posts
    111


    In your original post you said that the you created a form with a subform and now your user prefers to have a button that calls the subform.

    So why don't you just put it back how it was and then hide and unhide the subform with a toggle button.

    You could also have a linked form to your main form, you then put a command button on the main form and when clicked it will open the linked form and show the records related to the main form.

    Post back if you want any more information.
    Regards,



    John A

  6. #6
    Join Date
    Sep 2001
    Posts
    175
    Sorry for not making myself clear in the beginning. Apparently it is a linked form I am looking for. When I first created the form it was a main form/sub form. Now I added a button to my main form so that when it is pressed, is opens what use to be the sub form showing all the related records. However when I try to enter new info, it is not saving.

    What am I doing wrong????

  7. #7
    Join Date
    Aug 2002
    Location
    Melbourne, Australia
    Posts
    111

    Talking

    If you want to add information to the sub form and have it saved and linked to the main form then you have to use form and subform. I will stand corrected, if I am wrong.

    I would use a form and linked form to view information (example would be say customer form and the linked form maybe the contacts for that company.

    I have attached a an example of a main form and sub form. You can hide the subform with the aid of a toggle button.

    This is not mine I download an access database from microsoft that has examples of "forms"

    Hope this helps
    Attached Files Attached Files
    Regards,



    John A

  8. #8
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820
    Originally posted by toukey1
    Sorry for not making myself clear in the beginning. Apparently it is a linked form I am looking for. When I first created the form it was a main form/sub form. Now I added a button to my main form so that when it is pressed, is opens what use to be the sub form showing all the related records. However when I try to enter new info, it is not saving.

    What am I doing wrong????
    your problem is that the linked form isn't normaly really linked it's filtered to only show the linked fields which means that unless you manualy create the link on a new record (ie choose the value that goes in the secondary key) it is saved with the linked field set to the default (which may be null) if you look at the base tables the data should have been saved but not linked, there are a couple of ways round this
    1. show the field and make sure the user puts the value in
    2. the other way
    the called form should have this behind it (if you used the wizard)
    Code:
    Sub Form_Load()
        If ParentFormIsOpen() Then Forms![<parentform>]!ToggleLink = True
    End Sub
    Sub Form_Unload(Cancel As Integer)
        If ParentFormIsOpen() Then Forms![<parentform>]!ToggleLink = False
    End Sub
    Private Function ParentFormIsOpen()
        ParentFormIsOpen = (SysCmd(acSysCmdGetObjectState, acForm, "<parentform>") And acObjStateOpen) <> False
    End Function
    you need to change the form load to read
    Code:
    Sub Form_Load()
        Me.<linked field>.DefaultValue = Form_<parentform>.<linkedfield>
        If ParentFormIsOpen() Then Forms![<parentform>]!ToggleLink = True
    End Sub
    if this isn't how yours looks, let me know how yours is and i'll addapt it to fit
    Last edited by m.timoney; 05-21-03 at 07:57.
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

  9. #9
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820
    i nearly forgot you also need to change
    Code:
    Private Sub FilterChildForm()
        If Me.NewRecord Then
            Forms![<childform>].DataEntry = True
        Else
            Forms![<childform>].Filter = "[<linkedfield>] = " & Me.[<linkedfield>]
            Forms![<childform>].FilterOn = True
        End If
    End Sub
    in the parent form to read
    Code:
    Private Sub FilterChildForm()
        If Me.NewRecord Then
            Forms![<childform>].DataEntry = True
        Else
            form_<childform>.<linkedfield>.defaultvalue = me.<linkedfield>
            Forms![<childform>].Filter = "[<linkedfield>] = " & Me.[<linkedfield>]
            Forms![<childform>].FilterOn = True
        End If
    End Sub
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

  10. #10
    Join Date
    Sep 2001
    Posts
    175
    As mentioned initially, the called form opens with a button on the main form is pressed and has the following code:

    Private Sub bolbutton_Click()
    On Error GoTo Err_bolbutton_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "calledformname"

    stLinkCriteria = "[linkedfield]=" & "'" & Me![linkedfield] & "'"
    DoCmd.OpenForm stDocName, , , stLinkCriteria

    Therefore I don't have the Form_Load code you referred to. I tried putting the following code but I got an error with 'ParentFormIsOpen'

    Sub Form_Load()
    Me.<linked field>.DefaultValue = Form_<parentform>.<linkedfield>
    If ParentFormIsOpen() Then Forms![<parentform>]!ToggleLink = True
    End Sub

    What should I do????

  11. #11
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820
    ah i was expecting you to have used the form wizard

    try it with out the
    If ParentFormIsOpen() Then Forms![<parentform>]!ToggleLink = True

    as you haven't got the ParentFormIsOpen sub and if that don't work send a zipped up copy of the DB to REMOVED and i'll adapt my fix to you db and get it back asap
    Last edited by m.timoney; 05-22-03 at 07:25.
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

  12. #12
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820
    got your email, see if this works
    Attached Files Attached Files
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

Posting Permissions

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