Results 1 to 10 of 10
  1. #1
    Join Date
    Feb 2004
    Posts
    41

    Unanswered: Updating Data on a form

    I have a form and when the user enter a number into atext box i want the related data (displayed in a subform to be updated) - As it is now, when i change the number in the text box i have to click somewhere within the subform before it will change - i know i prob need to use the code builder but im not quite sure what to code - does anyone have any ideas?!
    Thanxs

  2. #2
    Join Date
    Feb 2004
    Location
    Binary Universe
    Posts
    57
    First create [On Change] event procedure for your control in form's design view.

    Second in vb code execute the following:

    Private Sub ControlName_OnChange

    Forms!subFormName.ControlName = ControlName.Value
    'or just
    Forms!subFormName.ControlName = ControlName

    End Sub
    I won't byte... hard!

  3. #3
    Join Date
    Feb 2004
    Posts
    41
    It keeps saying it cant find the subform but its names correctly and i cant think of what else it could be?

  4. #4
    Join Date
    Feb 2004
    Location
    Binary Universe
    Posts
    57
    Is the sub form a pop up?

    It has to be opened before you can update controls.
    If it's a pop up then create [On Load] event procedure for the sub form and do this:

    Private Sub Form_Load

    ControlName = Forms!mainFormName.ControlName.Value
    or just
    ControlName = Forms!mainFormName.ControlName

    End Sub
    I won't byte... hard!

  5. #5
    Join Date
    Feb 2004
    Posts
    41
    No its not a pop up, its already open on the form!!!!

  6. #6
    Join Date
    Feb 2004
    Location
    Binary Universe
    Posts
    57

    Re: Updating Data on a form

    How about this then:

    First create [On Change] event procedure for your control in form's design view.

    Second in vb code execute the following:

    Private Sub ControlName_OnChange

    Forms!subFormName.SetFocus
    Forms!subFormName.ControlName = ControlName.Value
    'or just
    Forms!subFormName.ControlName = ControlName

    End Sub

    Also can you post the exact text of the error message that you're getting?
    I won't byte... hard!

  7. #7
    Join Date
    Feb 2004
    Posts
    41
    it says:

    Microsoft Access cant find the form "frmClientSubform" referred to in a Macro expression or Visual Basic code.

    I tried adding in the SetFocus as well but that didnt work either!

    One thing is that when im entering in the frmClientSubform. - Theres no prompt thing giving you the options to setFocus - I cant figure out why its not finding the form!

  8. #8
    Join Date
    Feb 2004
    Location
    Binary Universe
    Posts
    57
    Question:
    Do the main form and subform have the same underlying table?

    If they do then just bind both controls to the same table field and in [On Change] put:
    DoCmd.RunCommand acCmdSaveRecord

    If not lemme think about it. I just re-created the situation in a db and I get the same error message.
    I won't byte... hard!

  9. #9
    Join Date
    Feb 2004
    Location
    Binary Universe
    Posts
    57
    Assuming that both input/text controls have inderlying table fields.

    Try this:

    Open main form in design view.
    Open 'Properties' dialog box for the subform.
    Click on 'Data' tab.

    You'll see 'Link Child Field' and belove 'Link Master Field' lines.
    Put the curson in one of them and click on three dots '...' on the right.
    'Subform Field Linker' dialog box should pop up. In it you can choose which controls you want to be updated automatically after that contol looses focus.

    See attached db as an example.
    Attached Files Attached Files
    I won't byte... hard!

  10. #10
    Join Date
    Feb 2004
    Posts
    41
    jeez thanxs for all the effort you went to!!
    Still having problems though cos when i click on the three dots im getting - the expression you entered refers to an object that is closed or doesnt exist - Im going mad with this!!! Have you any other ideas?!!!!

Posting Permissions

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