Solved

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

Posted on 2015-01-14
4
402 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
Comment Utility
If the function is public, you can all it like this:

  Call Me!NameOfSubformControl.Form.FCDB()

/gustav
0
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
Comment Utility
in the click event of the button place this codes

Private Sub btnName_Click()

Form_frmFCDBHeader.FCDB

end sub
0
 
LVL 34

Expert Comment

by:PatHartman
Comment Utility
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
Comment Utility
Thanks
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
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…
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…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

743 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now