Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Join Date
    Feb 2004
    Posts
    41

    Unanswered: Updating data in subform!!!

    I want to be able to be able to enter a value into a combo box or a text box and i want a subform to bring up the data related to the number entered into the combo/text box! Its driving me mad because it was working on one of the combo boxes and i hadnt coded anything in for it at all and now its not working for any of them!!! PLEASE HELP!!!

  2. #2
    Join Date
    Nov 2003
    Location
    Australia
    Posts
    36
    there are lots of ways to do this
    ... mabye put something like this in u;re combo on the after update event:

    ChildName.Form.Filter = "filterField='" & ComboBoxName & "'"
    ChildName.Form.FilterOn = True

  3. #3
    Join Date
    Feb 2004
    Location
    Binary Universe
    Posts
    57
    This works:

    Let's say you have a cumbo box with values '1; 2; 3' which correspont to a table's 'tblSub' indexed IDs.

    When you select a value from combo box the sub form 'frmSub' displays records from 'tblSub' with ID = cumbo box value.

    How it works:

    In the [On Change] event procedue for the cumbo box do the following:

    frmSub.Form.RecordSource = "SELECT * FROM tblSub WHERE [ID]=" & cmbCumboBoxName

    Also in the frmSub's [On Load] event procedure:

    Form.RecordSource = "SELECT * FROM tblSub WHERE [ID]=" & Parent.cmbCumboBoxName

    See the attached db as an example.
    Attached Files Attached Files
    Last edited by The Byte; 02-17-04 at 09:18.
    I won't byte... hard!

  4. #4
    Join Date
    Feb 2004
    Posts
    41
    When you say child name do you mean the name of the subform?
    When i do this:

    frmFaultReportSubform.Form.Filter = "filterField='" & cboStaffAllocated.Text & "'"
    frmFaultReportSubform.Form.FilterOn = True

    Im getting "Object Required"
    Any Ideas?

  5. #5
    Join Date
    Feb 2004
    Location
    Binary Universe
    Posts
    57
    Ooops. I changed the combo box name and forgot to change event procedure's.

    Here's the one that works.
    Attached Files Attached Files
    I won't byte... hard!

  6. #6
    Join Date
    Feb 2004
    Posts
    41
    Byte im getting the same error with your solution!!!

  7. #7
    Join Date
    Feb 2004
    Location
    Binary Universe
    Posts
    57
    One more try.

    See the db for clues! This one really works.
    Attached Files Attached Files
    I won't byte... hard!

  8. #8
    Join Date
    Feb 2004
    Posts
    41
    For some reason its not working - Its not recognising the subform i dont think cos when i type in the name and put dot after it no propmt is coming up - would you know the reason for this? its definately named correctly!!

  9. #9
    Join Date
    Feb 2004
    Location
    Binary Universe
    Posts
    57
    That would mean that you don't have the correct sub form's name.
    Usually if there's a room for a typos I switch to the forms tab then hightlight the form I need a name of then press F2 (rename) followed by 'Ctrl-C'. This puts form's name on Windows clipboard and you can paste it in your code without typing it. Some clients have a crappy naming practices and this usually works.

    Another way to find it in 'Me.subFormName'
    Last edited by The Byte; 02-17-04 at 09:56.
    I won't byte... hard!

  10. #10
    Join Date
    Feb 2004
    Posts
    41
    No its definately named correctly!

  11. #11
    Join Date
    Feb 2004
    Location
    Binary Universe
    Posts
    57
    Well, that's the whole different ball game. Sounds like a db is all crapped up.

    Try this:

    Do compact and repair.
    See if the sub form's name is on Me.'Objects...' list
    Rename the sub form and see if you'll get a pop-up after a dot with the new name. Remane to the old name and check again.
    Import all your tables/forms/reports etc... into a blank db and compile the vb code.

    Can somebody think of something else to do?

    btw, does my sample db update the sub form?
    Last edited by The Byte; 02-17-04 at 11:46.
    I won't byte... hard!

  12. #12
    Join Date
    Dec 2003
    Location
    Toronto, Ont. Canada
    Posts
    238
    Originally posted by jill83
    No its definately named correctly!
    Referring to subforms, main forms... their controls and/or properties can be tricking syntax at times...

    Here is a wonderful link (that I have printed and still refer to!) that you should keep handy...
    http://www.mvps.org/access/forms/frm0031.htm

    Now... If you are on the Main form and you want to refer to a property (ie Filter) on a subform... This is the syntax...

    Me!Subform1.Form.RecordSource
    (where Subform1 is the name of the subform CONTROL on your main form...)

    So give this a try...

    Me!YourSubFormControlName.Form.Filter = "filterField='" & Me!cboStaffAllocated & "'"
    Me!YourSubFormControlName.Form.FilterOn = True

    HTH

  13. #13
    Join Date
    Dec 2003
    Location
    Toronto, Ont. Canada
    Posts
    238
    Originally posted by The Byte
    Well, that's the whole different ball game. Sounds like a db is all crapped up.

    Try this:

    Do compact and repair.
    See if the sub form's name is on Me.'Objects...' list
    Rename the sub form and see if you'll get a pop-up after a dot with the new name. Remane to the old name and check again.
    Import all your tables/forms/reports etc... into a blank db and compile the vb code.

    Can somebody think of something else to do?

    btw, does my sample db update the sub form?
    Yes, your sample does update the subform...

  14. #14
    Join Date
    Feb 2004
    Posts
    41
    It keeps bringing up an input box with filterField in it?!!!

  15. #15
    Join Date
    Dec 2003
    Location
    Toronto, Ont. Canada
    Posts
    238
    Originally posted by jill83
    It keeps bringing up an input box with filterField in it?!!!
    You have to change that to the name of the field in the subform's recordsource that should match the value in the combo box...

Posting Permissions

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