Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2004
    Posts
    214

    Unanswered: VB Code Help LinkChildFields

    I have a command button so that when clicked my blank subform will become visible, the source object will link to the particular form based on which command button they choose, and the master fields link to a combo box 83 on my main form and the child fields link to a combo69 on my Demo Form.

    I am having problems with the Child Link. Can anyone help me out with this. I don't know VB as well as should.


    Private Sub Label55_Click()

    Child85.Visible = True

    Child85.SourceObject = "Demo Form"
    Child85.LinkMasterFields = Combo83.Value
    Child85.LinkChildFields = Combo69.Value
    Child85.Requery
    You know, I'm sick of following my dreams, man. I'm just going to ask where they're going and hook up with 'em later

  2. #2
    Join Date
    Feb 2004
    Posts
    214

    ...

    the problem in the code is with: Child85.LinkChildFields = Combo69.Value

    Combo69 is on my subform, but I don't know enough about vb to point it to the form and then to the combo box.

    Any suggestions?
    You know, I'm sick of following my dreams, man. I'm just going to ask where they're going and hook up with 'em later

  3. #3
    Join Date
    Sep 2002
    Location
    South Wales
    Posts
    580
    Use a temporary object so you can reference it;

    dim cntrl As control
    set cntrl = forms!MainFormName.SubformName.form.Combo69

    Child85.LinkChildFileds = cntrl.value

    set cntrl = nothing

    <Try that for size - Typed on the fly so let me know if it doesnt work!
    Windows Server 2003-8 / Terminal Services / SQL 2000 / Access 2003 / Office 2003-7 / Exchange 2003-7 / Blackberry Enterprise Server / AutoCAD / Lambert And Butler / Red Bull

  4. #4
    Join Date
    Feb 2004
    Posts
    214

    Talking Thanks for the help

    I tried working with that code and tried changing different things with it and still got the same type of error messages as before. I am actually going a different route and it appears to be working. I appreciate the help though
    You know, I'm sick of following my dreams, man. I'm just going to ask where they're going and hook up with 'em later

  5. #5
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Another method I use without having to worry about the .LinkChildFields and .LinkMasterFields is...

    1. I make it so the rowsource query of the subform has criteria such as "Select * from MySubTable where IDField = " & Forms!MyMainFormName!IDField & ""
    2. I make sure the IDField is on the subform and the default value is =Forms!MyMainFormName!IDField. (you can make the IDField invisible.) If not invisible, make sure to lock and disable it.

    And then I don't really have to worry about the .LinkChildFields and .LinkMasterFields.

    Also, Combo69 and Child85 is a really bad naming convention to use (as well as Label55_Click). Using these names will make your life miserable in the future when you need to come back and change any code (but you probably already know that.)
    Last edited by pkstormy; 11-08-08 at 01:18.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

Posting Permissions

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