Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

I need to run vba code in a subform from the main form

Posted on 2015-01-14
4
Medium Priority
?
417 Views
Last Modified: 2015-01-18
The main form has a button to find a record.  I have a subform on the main form that has vba code to open a recordset and show a list of records.  I would like that to happen when I click on the button on the main form.

I just need the code to be able to reference the vba in the subform from the main form so it will run.

Main form name: frmMain
Subform name: frmFCDBHeader

The code that needs to be called n the subform is: Public Sub FCDB()

Thanks,
Scott
0
Comment
Question by:Scott Palmer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 51

Expert Comment

by:Gustav Brock
ID: 40549652
If the function is public, you can all it like this:

  Call Me!NameOfSubformControl.Form.FCDB()

/gustav
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 40549659
in the click event of the button place this codes

Private Sub btnName_Click()

Form_frmFCDBHeader.FCDB

end sub
0
 
LVL 39

Expert Comment

by:PatHartman
ID: 40551857
Is there some particular reason that you are working with unbound forms?

If the subform were bound, it's Recordsource query could reference a control on the mainform to get selection criteria:

WHERE somefield = Forms!MyForm!somefield

Then in the click event of the button, you would requery the subform.

Me.sfrmName.Requery
0
 

Author Closing Comment

by:Scott Palmer
ID: 40556743
Thanks
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question