Results 1 to 7 of 7
  1. #1
    neo651 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2011
    Posts
    110

    Referencing a Control in a Subform from a macro

    So I've got 3 forms



    frmPrices (Main Form)
    frmStipulations (Subform)
    frm_AddStipulations

    frmStipulations is a subform inside of frmPrices. frmStipulations contains a combobox (cboStipulationID). If a Stipulation that doesn't yet exist needs to be entered there is a button called btnAddStipulation. This button opens frm_AddStipulations. I want to create a macro in frmPrices that will take whatever value was just added in frmAddStipulations and insert it as a new entry in frmStipulations. The trouble is I can't figure out or find the appropriate syntax for referencing cboStipulationID inside of frmStipulations from frmPrices. Everything I try just throws "The control name blahblahblah is misspelled or refers to a control that doesn't exist."

    Anyone know how this is supposed to be done?

  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,518
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    neo651 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2011
    Posts
    110
    Oh dear sweet Jesus I could kiss you. I don't know why I couldn't find that. It's so beautiful.....thank you...

  4. #4
    neo651 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2011
    Posts
    110
    No......i spoke too soon. I was just so happy to see it all laid out to nearly but it still won't work. I dropped the macro and switched to vba and used the chart you linked me to. I was careful to use the subform's control name in the mainform and I've quadruple checked all my spellings, dots and exclamation points. But when I run the code I get what I think is just the equivalent error as before but for vba:

    "Microsoft Access can't find the field cboStipulationID referred to in your expression."

    Sigh...

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    What is your code?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    This is NOT a navigation form?

    Might consider NotInList event of combobox. http://www.fontstuff.com/access/acctut20.htm
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    neo651 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2011
    Posts
    110
    Code:
    Private Sub btnAddStipulation_Click()On Error GoTo btnAddStipulation_Click_Err
    
    
    
    
        DoCmd.OpenForm "frm_Stipulations", acNormal, "", "", , acDialog
        DoCmd.SetProperty Me!sbfrm_Jn_Prices_Stipulations.Form!cboStipulationID, , TempVars!varStipulationID
        DoCmd.Requery Me!sbfrm_Jn_Prices_Stipulations.From!cboStipulationID
    
    
    
    
    btnAddStipulation_Click_Exit:
        Exit Sub
    
    
    btnAddStipulation_Click_Err:
        MsgBox Error$
        Resume btnAddStipulation_Click_Exit
    
    
    End Sub

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

Similar Threads

  1. Replies: 3
    Last Post: 03-29-2013, 02:36 PM
  2. Replies: 3
    Last Post: 02-15-2013, 03:36 PM
  3. Replies: 2
    Last Post: 09-13-2012, 12:25 PM
  4. VBA Referencing Subform Control Error 2465
    By Jester0001 in forum Programming
    Replies: 3
    Last Post: 05-30-2012, 07:31 AM
  5. referencing a control
    By looloo in forum Programming
    Replies: 3
    Last Post: 09-23-2011, 07:57 PM

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