473,606 Members | 2,453 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Subform's record source

I need to get at a subofmr's recordsource in code. I want to change the
recordsource dynamically. I thought this would be straight forward..but I
keep getting errors.

On Event

forms!Mainform! subform!records ource = "somequery"

End sub

I've also tried variations of this Me.subforms.rec ordsource
and Forms!mainform. subform.records ource..
returns various errors such as object doesn support this propery etc.

I'm guessing I'm just not getting the syntax right or something.

Anyone see where I'm going wrong?
Jul 14 '06 #1
2 6248
Try:
Me.[sub1].Form.RecordSou rce = "Query1"
where sub1 represents the name of the subform control.

If the .Form bit is new to you, see:
http://allenbrowne.com/casu-04.html
Basically, the subform control does not have a RecordSource; the form in the
subform control does.

If it still fails, perhaps the Name of the subform control is different than
the name of the form it contains.

When you change the RecordSource, Access will have a guess at the
LinkMasterField s/LinkChildFields , but it may not be what you want.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"shifty shaker" <SS***@pioneers .netwrote in message
news:i_******** *********@news0 2.roc.ny...
>I need to get at a subofmr's recordsource in code. I want to change the
recordsource dynamically. I thought this would be straight forward..but I
keep getting errors.

On Event

forms!Mainform! subform!records ource = "somequery"

End sub

I've also tried variations of this Me.subforms.rec ordsource
and Forms!mainform. subform.records ource..
returns various errors such as object doesn support this propery etc.

I'm guessing I'm just not getting the syntax right or something.

Anyone see where I'm going wrong?

Jul 14 '06 #2
The link master and child fields will be the same for all iterations of
this...if access doesn't do too much guessing I should be ok?

Thanks for the reply.

"Allen Browne" <Al*********@Se eSig.Invalidwro te in message
news:44******** *************** @per-qv1-newsreader-01.iinet.net.au ...
Try:
Me.[sub1].Form.RecordSou rce = "Query1"
where sub1 represents the name of the subform control.

If the .Form bit is new to you, see:
http://allenbrowne.com/casu-04.html
Basically, the subform control does not have a RecordSource; the form in
the subform control does.

If it still fails, perhaps the Name of the subform control is different
than the name of the form it contains.

When you change the RecordSource, Access will have a guess at the
LinkMasterField s/LinkChildFields , but it may not be what you want.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"shifty shaker" <SS***@pioneers .netwrote in message
news:i_******** *********@news0 2.roc.ny...
>>I need to get at a subofmr's recordsource in code. I want to change the
recordsourc e dynamically. I thought this would be straight forward..but I
keep getting errors.

On Event

forms!Mainform !subform!record source = "somequery"

End sub

I've also tried variations of this Me.subforms.rec ordsource
and Forms!mainform. subform.records ource..
returns various errors such as object doesn support this propery etc.

I'm guessing I'm just not getting the syntax right or something.

Anyone see where I'm going wrong?


Jul 14 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2843
by: CSDunn | last post by:
Hello, In an Access 2003 ADP Subform, I am trying to set the BackGround color of three textbox fields (LSScore, RScore, WScore) in the current record of the subform to zero (black) if the value of a bound checkbox field (Spanish) on the current record is True, and to 16777164 if the value of the bound checkbox field is False. The Subform's Name property is 'frmMainScores'. The Source Object Property of the Subform is 'frmMainSubScores'....
25
10203
by: Lyn | last post by:
Hi, I am working on a genealogy form. The only table (so far) lists everybody in the family, one record per person. Each record has an autonum ID. The parent form (frmMainForm) displays the data in each record, which includes the ID of the father and the mother (who also have records in the table). One record per form. I have a Tab Control in the form, and in one of the tabs I have a subform (sfmSiblings) in which I wish to list...
3
4493
by: Nicolae Fieraru | last post by:
Hi All, I have a problem and I can't figure out how to solve it. My database has three tables: tblCustomers, with CustomerId and CustomerName tblProducts, with ProductId and ProductCode tblPurchases, with PurchaseId, CustomerId and ProductId I created a form with a subform which shows all the customers, one at a time
4
6995
by: Dave Boyd | last post by:
Hi, I have two very similar forms each with a subform. The main form gets a few fields from the user and passes this back to a query that the subform is bound to. The requery is done when the user enters the last qualifying field on the main form. In one case this works fine, the subform shows the data the user wants to update -- which means showing all the data put in previously (ie showing this via the requery and the continuous...
5
5244
by: tdmailbox | last post by:
I have a form with a child form. In the child form there is a list of names that can grow quite large. On the parent form I want to display the first name from the child form. I set up a test box that is populated with the code =subfrm_media_review_sec_party.Form!first_name & " " & subfrm_media_review_sec_party.Form!last_name It works except that when I flip through the names it populates the parent form with the name of what ever...
0
1929
by: johnson_cy | last post by:
I am using Access 2000. My main form has a record source of a table (employeeTbl with key of . It is filtering the record results. My subform and mainform have the link child/link master set to and the source object is the subform. My subform record source is a query from another table (vacationTbl). FYI: I was filtering on the subform, but removed it and replaced with
1
2689
by: kkrizl | last post by:
I have a form that displays general information about an alarm permit location. There's a subform that shows detailed information about burglar alarms that have gone off at the location. When a new alarm is entered on the subform, I want to print a report that shows the general information and the alarms that were entered. The record source for the form is the Mailing List table (key is Alarm #). The record source for the subform is the...
6
5596
by: Bob Quintal | last post by:
Using Access '97. I have a subform, where the .AllowAdditions property is set to false. I have a button labelled 'Add record' that sets this property = true, followed by a DoCmd.gotoRecord acNewRecord. a Save button sets me.dirty = false; me.AllowAdditions = False a Cancel button sets me.undo; me.AllowAdditions = False This works correctly.
9
9678
by: Ecohouse | last post by:
I have a main form with two subforms. The first subform has the child link to the main form identity key. subform1 - Master Field: SK Child Field: TrainingMasterSK The second subform has a master-child link to the first subform. subform2 - Master Field: subTrainingModule.Form!TrainingModuleTopicSK Child Field: TrainingModuleTopicSK
1
2186
by: Kev | last post by:
Hello I have a form (RosterForm) based on a table - RosterRange RosterRange has 4 fields: RosterRangeID Autonumber RosterStartDate Date RosterEndDate Date (probably unnecessary) Ward Text I have 2 unbound combo boxes looking up values - cmbDepartment and
0
8024
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8449
Oralloy
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...
1
8105
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8310
tracyyun
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...
0
6781
agi2029
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...
1
5968
isladogs
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...
0
5466
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();...
0
3987
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2451
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.