Results 1 to 4 of 4
  1. #1
    Cheshire101 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Dec 2009
    Posts
    42

    Question Subform Change - Run-time error 2101

    I have a main form with a sub form on it that I would like to change depending on a drop down field selected on the main form, below is the code I was trying but can not make it work.
    Dim varX

    varX = DLookup("txtPNJobCode", "tblPartNumber", "txtPNPartNo = '" & Me.txtInspPNumber & "'")

    If varX = "1322" Then
    Me.SubForm.SourceObject = frmPAInspSub
    Me.SubForm.LinkChildFields = txtPANPartNumber
    Me.SubForm.LinkMasterFields = txtInspPNumber
    ElseIf varX = "1318" Then
    Me.SubForm.SourceObject = frmGDInspSub
    Me.SubForm.LinkChildFields = txtGDSNPartNumber
    Me.SubForm.LinkMasterFields = txtInspPNumber
    End If
    Error received: The setting you entered isn't valid for this property. (Run-time error '2101')


    The lookup is working fine the line of code being highlighting for debugging is the link field lines.

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows XP Access 2002
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Try:
    Code:
    If varX = "1322" Then
       Me.SubForm.SourceObject = frmPAInspSub
       Me.SubForm.LinkChildFields = """txtPANPartNumber"""
       Me.SubForm.LinkMasterFields = """txtInspPNumber"""
    ElseIf varX = "1318" Then
       Me.SubForm.SourceObject = frmGDInspSub
       Me.SubForm.LinkChildFields = """txtGDSNPartNumber"""
       Me.SubForm.LinkMasterFields = """txtInspPNumber"""
    End If

  3. #3
    Cheshire101 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Dec 2009
    Posts
    42
    Ok changed the code to this:
    Select Case DLookup("txtPNJobCode", "tblPartNumber", "txtPNPartNo = '" & Me.txtPNumber & "'")
    Case "1322"
    Me.SubForm.SourceObject = "frmPAInspSub"
    Me.SubForm.LinkChildFields = ""
    Me.SubForm.LinkMasterFields = ""
    Me.SubForm.LinkChildFields = "txtPANPartNumber"
    Me.SubForm.LinkMasterFields = "txtPNumber"
    Case "1318"
    Me.SubForm.SourceObject = "frmGDInspSub"
    Me.SubForm.LinkChildFields = ""
    Me.SubForm.LinkMasterFields = ""
    Me.SubForm.LinkChildFields = "txtGDSNPartNumber"
    Me.SubForm.LinkMasterFields = "txtPNumber"
    End Select

    Which works fine unless the user changes the field and the second time the case is different, then the system gives an error for a parameter value of the other case for the link field information.
    I tried yours but still same problem.

  4. #4
    Cheshire101 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Dec 2009
    Posts
    42
    I think I need some kind of reset on before update but I can not think of how to do this.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Color/font change in subform
    By AndyKim in forum Forms
    Replies: 9
    Last Post: 06-24-2009, 04:34 PM
  2. Run Time Error 3265
    By duckie10 in forum Access
    Replies: 5
    Last Post: 05-13-2009, 09:27 AM
  3. Run-time error 2001
    By RONY in forum Programming
    Replies: 0
    Last Post: 12-23-2008, 06:09 AM
  4. Run time error '6': Overflow
    By wasim_sono in forum Access
    Replies: 0
    Last Post: 06-22-2007, 06:44 AM
  5. Run Time Error 424
    By ddog171 in forum Programming
    Replies: 3
    Last Post: 02-04-2006, 07:13 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums