Results 1 to 9 of 9
  1. #1
    CementCarver's Avatar
    CementCarver is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2013
    Location
    Canada
    Posts
    231

    Test Subform Control Name Access 2010

    I'm getting a run time error 2465 can't find controls for the line below:



    If ctl = Forms![frm_EDIT_CURRENT_PACKER]![EDIT_PACKER_TRACEABILITY].Form!Controls(MEMBER_ID) Then

    I'm trying to go through each control in my subform but I'm initially testing whether it matches one of the control names.

    Can anyone see what's wrong with this line?

    CementCarver

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    Using that method I believe the control name has to be in quotes. I use:

    http://access.mvps.org/access/forms/frm0031.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    CementCarver's Avatar
    CementCarver is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2013
    Location
    Canada
    Posts
    231
    PBaldy, I get the same error..... with this line.....

    If ctl = Forms![frm_EDIT_CURRENT_PACKER]![EDIT_PACKER_TRACEABILITY].Form!Controls("MEMBER_ID") Then

    CementCarver

  4. #4
    CementCarver's Avatar
    CementCarver is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2013
    Location
    Canada
    Posts
    231
    But if I try this line:

    If ctl = Forms("frm_EDIT_CURRENT_PACKER").Controls("EDIT_PA CKER_TRACEABILITY").Form.Controls("MEMBER_ID") Then

    I get an error Object doesn't support this property or method.....?

    CementCarver

  5. #5
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by CementCarver View Post
    But if I try this line:

    If ctl = Forms("frm_EDIT_CURRENT_PACKER").Controls("EDIT_PA CKER_TRACEABILITY").Form.Controls("MEMBER_ID") Then

    I get an error Object doesn't support this property or method.....?

    CementCarver
    What is ctl ? Did you make a declaration for ctl somewhere?

  6. #6
    CementCarver's Avatar
    CementCarver is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2013
    Location
    Canada
    Posts
    231
    I'm trying to retrieve values from a subform and testing whether the values have changes in the subform's datasheet view. And if they've changed, then I write those changes to the audit table.

    Dim ctl As Control
    Dim frmCurrentForm As SubForm

    Set frmCurrentForm = Forms!frm_EDIT_CURRENT_PACKER!EDIT_PACKER_TRACEABI LITY
    For Each ctl In frmCurrentForm.Controls
    If ctl = Forms("frm_EDIT_CURRENT_PACKER").Controls("EDIT_PA CKER_TRACEABILITY").Form.Controls("MEMBER_ID") Then .......This line causes an error object not supported.......
    If ctl.Tag = "Audit" Then
    MEMBER_ID_new = Nz(Forms!frm_EDIT_CURRENT_PACKER!EDIT_PACKER_TRACE ABILITY.Form.MEMBER_ID.Value)
    MEMBER_ID_old = Nz(Forms!frm_EDIT_CURRENT_PACKER!EDIT_PACKER_TRACE ABILITY.Form.MEMBER_ID.OldValue)

    If MEMBER_ID_new <> MEMBER_ID_old Then
    With rstAudit
    .AddNew
    ![DateTime] = datTimeCheck
    ![UserName] = strAccountName
    ![FormName] = frmCurrentForm
    ![Action] = UserAction
    ![Record_ID] = MasterFormMember_id
    ![FieldName] = ctl.ControlSource
    ![OldValue] = ctl.OldValue
    ![NewValue] = ctl.Value
    .Update
    'Debug.Print "Current values " & UserAction
    End With

    End If
    End If

    CementCarver

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    I'd try

    If ctl.Name = "MEMBER_ID" Then
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    CementCarver's Avatar
    CementCarver is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2013
    Location
    Canada
    Posts
    231
    Bang on PBaldy....... That worked like a charm...... I owe you one.....CementCarver

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    Happy to help.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 6
    Last Post: 02-28-2015, 01:23 PM
  2. Replies: 6
    Last Post: 07-11-2013, 07:05 AM
  3. Access 2010 Calendar Control
    By burrina in forum Forms
    Replies: 21
    Last Post: 05-20-2013, 04:50 AM
  4. Replies: 3
    Last Post: 04-21-2013, 06:48 AM
  5. Keying in Test answers to Access DB from Written Test
    By CityOfKalamazoo in forum Access
    Replies: 3
    Last Post: 03-01-2010, 08:58 AM

Tags for this Thread

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