none
Subform problem adding new record RRS feed

  • Question

  • I have a main form with  juvenile demographics.  I created the tab control alternative for handling subforms - each tab opens a different subform.

    If the juvenile is known to the database, I don't want to create a new juvenile record. However I do want to create a new delinquency record in the subform  Here is my problem:

    I do a search, and if the juvenile is found I start with that record on the parent form.  I click the tab which brings up the existing juvenile record.  I click on the "Add Record" control, and it looks like everything is well.  I am able to enter in the screener, and I can choose the option in the first option group,  all of which is attached to a new delinquency record with a new ID.  Then, I click on the second option group on the same form and everything is reset and the form is filled in with the data from the first delinquency record in the delinquency table, no matter what juvenile that record was attached to.

    If I choose Data Entry for the Delinquency subform, all is well until I click on one of the other tabs and then re-click the Delinquency tab to see what I had entered on the delinquency form - which of course has been cleared and is ready to accept a new record.

    I would like to have the existing juvenile form look the same as the initial juvenile form for ease of use, but I have not been able to find a way.  Thanks

    Saturday, October 21, 2017 11:18 PM

All replies

  • > everything is reset and the form is filled in with the data from the first delinquency record in the delinquency table

    That seems to suggest you forgot to set the LinkMasterFields and LinkChildFields properties of the Subform control.

    Also for debugging purposes, make sure the form and subform show the Record Selector as well as the Navigation Buttons, so you can keep an eye on them and see when they change unexpectedly.


    -Tom. Microsoft Access MVP

    Saturday, October 21, 2017 11:29 PM
  • Thanks for the reply Tom.  Accessing the form using the tab doesn't expose the LinkMasterFields and LinkChildFields property.  I open up the delinquency form by clicking on a label that is made to look like a tab using this code:  

    Private Sub lblRefInfo_Click()
        Me.boxRefInfo.BackColor = 16777215
        Me.boxSources.BackColor = 14145495
        Me.boxDecision.BackColor = 14145495
        Me.subContainer.SourceObject = "AddKDAI_Referral-Info_Existing"
    End Sub

    The subContainer control does have those link properties available but when I try to use it I get the message that it can't be used with unbound forms. Is there anyway that I can create that link in the above click event?

    Sunday, October 22, 2017 1:34 AM
  • Why not follow the KISS principle and simply use a tab control with a separate bound subform on each page?  You'll find an example in FormsDemo.zip in my public databases folder at:

    https://onedrive.live.com/?cid=44CC60D7FEA42912&id=44CC60D7FEA42912!169

    Note that if you are using an earlier version of Access you might find that the colour of some form objects such as buttons shows incorrectly and you will need to amend the form design accordingly.

    If you have difficulty opening the link copy its text (NB, not the link location) and paste it into your browser's address bar.

    In this little demo file the 'Tabbed Form' option opens a form in which the main parent data is on the parent form above a tab control in which the subsidiary parent data is on page 1 of the tab control, and in which each subsequent page holds a subform.  In the demo the subforms are in continuous forms view, but they could equally well be in single form view, with an 'Add Record' button on each to move the record pointer to an empty new record by means of the GoToRecord method of the DoCmd object.

    Ken Sheridan, Stafford, England


    • Edited by Ken Sheridan Sunday, October 22, 2017 11:11 AM Hyperlink added.
    Sunday, October 22, 2017 11:10 AM
  • Unbound? You could have mentioned that since it is essential information.

    You wrote in first instance "I have a main form with juvenile demographics" and "I do want to create a new delinquency record in the subform". How is that unbound? Are you saving the data yourself? Bro, you're using the wrong tool. Do what 99% of all developers do: use bound forms and link them 1:M with LinkMaster and LinkChildFields properties.


    -Tom. Microsoft Access MVP

    Sunday, October 22, 2017 2:42 PM
  • Do what 99% of all developers do: use bound forms and link them 1:M with LinkMaster and LinkChildFields properties.

    Hi Tom,

    I think I am that 1% ...

    Imb.

    Sunday, October 22, 2017 4:32 PM
  • I think I am that 1% ...
    I think most of us realised that a long time ago, Imb.  À chacun son goût.

    Ken Sheridan, Stafford, England

    Sunday, October 22, 2017 5:03 PM