Go Back   Access World Forums > Microsoft Access Discussion > Modules & VBA

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 05-01-2017, 11:42 AM   #1
jwal
Newly Registered User
 
Join Date: Dec 2015
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
jwal is on a distinguished road
Command Button on SubForm Not Working on Main Form

Hello.
I have a main form (Form 1) that includes (2) subforms (Subform 1 and Subform 2). Subform 2 has a command button that opens PopForm 1 as a popup (VBA with use of OpenArgs). When Subform 2 is opened directly as the only form then the command button functions properly. When Subform 2 is opened as part of Form 1 and I click on the command button, I get "2450: cannot find the referenced form '.....'." Could someone please help me? TIA.

jwal is offline   Reply With Quote
Old 05-01-2017, 11:48 AM   #2
June7
AWF VIP
 
June7's Avatar
 
Join Date: Mar 2014
Location: The Great Land
Posts: 2,428
Thanks: 0
Thanked 568 Times in 564 Posts
June7 will become famous soon enough June7 will become famous soon enough
Re: Command Button on SubForm Not Working on Main Form

Post code for analysis.

Code that is designed to work when form is opened independently won't always work when used as a subform because it is then not an open form, it is the SourceObject of a subform container.
June7 is offline   Reply With Quote
Old 05-01-2017, 12:04 PM   #3
jwal
Newly Registered User
 
Join Date: Dec 2015
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
jwal is on a distinguished road
Re: Command Button on SubForm Not Working on Main Form

Code:
Sub Form 2
Public Sub cmdReassign_Click()

    strOpenArgs = Me.txtToolGroupID & "," & Me.txtEmployee_Name
    DoCmd.OpenForm "popfrmReassignGroupedTools", , , "ToolGroupID=" & Me.txtToolGroupID, , acWindowNormal, strOpenArgs


PopForm 1

Private Sub Form_Open(Cancel As Integer)
    
    If Not IsNull(Me.OpenArgs) Then
        
        Me.txtToolCategoryQty = Forms!subfrmToolReassignment_Grouped.txtToolCategoryQty
        Me.txtToolLocation = Forms!subfrmToolReassignment_Grouped.[txtEmployee Name]
        
    End If


Last edited by jwal; 05-01-2017 at 12:21 PM.
jwal is offline   Reply With Quote
Reply

Tags
command button , error 2450 , sub form , vba access 2016

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
command button in subform continuous form not working hockey8837 Forms 5 03-17-2014 04:13 PM
Moving from command button in main form to subform Toolman Forms 14 08-15-2011 12:23 PM
Hidding collum in a subform in datasheetview with a command button from the main form jostrep Forms 0 06-27-2005 06:03 AM
Subform command button makes main form jump to record MCantu Modules & VBA 1 12-27-2004 01:23 PM
setting focus to main form from subform command button ehdoh Forms 13 07-29-2003 09:53 AM




All times are GMT -8. The time now is 05:04 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World