Solved

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

Posted on 2015-01-14
4
405 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:ScootterP
4 Comments
 
LVL 49

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 500 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 35

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:ScootterP
ID: 40556743
Thanks
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

770 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