In Access 2007, my subform has 3 controls that filter data from queries based on user selections from the preceding controls using the requery macro. It works fine when I have only the subform open.
However, when I try to run it from the main form, the parameters do not pass to the next control. Instead, I get a dialog box to input the value. How do I get the subform to work from the main form? Thx.
15 12307 ADezii 8,834
Recognized Expert Expert @pl626
my subform has 3 controls that filter data from queries based on user selections from the preceding controls using the requery macro
Are you referring to a Combo Box on a Sub-Form? If so (Full Syntax): - Forms!<Main Form>!<Sub-Form Name>.Form!<Combo Box name>.Requery
You need to give a more technically detailed explanation on what it is you are doing. But if I were to guess, sounds like you may have a master-child linking issue, from the main form to sub form.
-AJ
@ADezii
Yes, I have 3 Combo Boxes in the Sub-form. As I understand it, that code should be on the main form correct? For which event should this code be assigned, 'On Got Focus'? Thx.
@ajalwaysus
AJ-thx for the quick response. My main form captures data for the header record of the parent table and the subform feeds a child table. The linkages are fine. There is no data that is being passed from the main form to the subform for these 3 controls. These 3 controls apply only to the subform data. The first control is a Combo-Box with values the user selects. This value is used to filter results for selection in the second combo box, which acts as a filter for the third. In the subform, i'm using the requery macro for this and it works fine when only the subform is open.
I've tried using 'Forms![main form![subform.Form![CNX Secondary].Requery' with various events and can't figure out how to get it to work.
First off, maybe you mistyped but your code should look like this: -
Forms![main form]![subform].Form![CNX Secondary].Requery
-
and just to cover the bases, just to make sure it was done, you replaced the [main form] and [subform] values with the actual names of your form, correct?
If this is still an issue, another option you could do, is to set the after update of each combo box to re-query the next combo box in the subforms VBA code.
Eaxmple: -
Sub ComboBox1_AfterUpdate()
-
ComboBox2.requery
-
End sub
-
-
Sub ComboBox2_AfterUpdate()
-
ComboBox3.requery
-
End sub
-
-AJ
AJ,
i did mistype in my response, the syntax i used is: - Private Sub Form_Load()
-
Forms![MainFormName]![subFormName].Form![controlname].Requery
-
End Sub
Is there are different event on the main form I should be using?
If all 3 of your combo boxes exist on the subform then you should code the After update code I provided above, directly in subFormName 's VBA code.
When coding on the same form as where the controls exists, you then don't have to worry where you place that subform, because the code is native to that form.
-AJ
NeoPa 32,568
Recognized Expert Moderator MVP @pl626
From this it seems you have omitted to change the text (MainFormName) to the actual name of your form. That is, unless it is actually called MainFormName, but that would be a very bad idea, so I'm sure you haven't. The same goes for the names of other objects in the reference of course.
Perhaps if you shared the names of all the object references involved on your form we could determine the full code reference for you if you need us to.
I updated the code in the subform and it works fine in the subform, but now when I run the subform from the main form, I get a "Run-time error '2450' " stating it can't find my subform. Do I need to add code in the main form to reference the subform?
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Bill Strass |
last post by:
Problem: Access main form/subform as front end to SQL Server backend.
Add/edit via subforms work fine. Not so with main form.
Set up a master-detail form-subform using two
views linked from SQL Server. The subform allows inserts an updates,
while the main form will not.
The only solution I can think of is to
recreate using tables imported from SQL Server, so that the data is
all
local. This is despite the fact that the views in SQL...
|
by: TDIOwa |
last post by:
I have a form (frmAppointment) with a subform on it
(frmAppointmentsub1). I have placed a command button on the main form
which calls the function below from the module. The purpose of this
function is to make fields beginning with YY invisble OnClick of the
command button on the main form. It works for the fields on the main
form but not on the subform. What do I need to add or do to make it
work on the subform? Any help would be...
|
by: prakashwadhwani |
last post by:
I have a (Main) form named : Stocks_Main
and a Subform in that named: Stocks_Data
The Subform is a continuous form
There is a field in the subform called QTY_IN
Now ... on the main form i.e. Stocks_Main I have set a text box to
display a total of the QTY_IN control (which is on the subform).
I am using the foll code as the control source for the text box
|
by: wideasleep |
last post by:
Hi everyone,
I have a subform that is a continuous form. It will have mutiple records that connect to a single record in the main form. I have set this up but running tests show only one record for each record in the main form. In the subform table it does show all the records but not in the form itself. I tried this with a datasheet view but get the same thing. I have the Master field set to the ID for the Parent and child field set for the...
|
by: Richnep |
last post by:
Hi all,.
I have a small issue I would like to resolve with VBA. I have a form
which
it's fields are bound to a table. Within that form is a subform which
is a
subtable.
Tables relationship is a one to many from the main table to the sub
table.
| |
by: ssr61 |
last post by:
hi
can u help me how to open a sub form with in a main form
without opening a new window.....
my main form (frm_searchby_Name)consists
of text field to enter the address and button
when i click the button a new subform window is opening...
|
by: reginaldmerritt |
last post by:
Not sure if this is even possible, but i want to select a field in a sub form from a main form. I want to populate a field in the main form with a sub forms field value.
eg.
me.name = subform.name
Not sure of the correct syntax to use.
All ideas and suggestions welcom
Thanks.
|
by: Bob Alston |
last post by:
I have a system where many subforms are used. Often the size of the
subform had to be larger than could be displayed without scrolling.
I set the height of the subform to the typical height appropriate for
the typical screen resolution they were using.
Now some users have decided to use higher screen resolutions, up to
1280/1024. When they maximize the form, that of course works but the
size of the main form control containing the...
|
by: ndeeley |
last post by:
Hello,
I've not had a lot of luck getting this to work, despite looking around lots of websites, so here goes...
I have a main form frmProjectScheduler. It's a tabbed form and the front page is a switchboard.
The front page shows a chart of uncompleted jobs, generated from a query qryUncompletedJobs. When a button next to this chart is clicked, a new form frmListUncompleted appears, showing the results of this query in a listbox,...
|
by: Fspinelli |
last post by:
I have a query by form set up.
I coded and can get the fields on the form to clear by the click of a button, but how do I make the subform clear, too?
The main form has a "Clear" button and in the "event procedure" I placed the following code:
Private Sub cmdClear_Click()
Me.txtFname = Null
Me.txtLname = Null
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |