473,320 Members | 1,825 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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!recordsource = "somequery"

End sub

I've also tried variations of this Me.subforms.recordsource
and Forms!mainform.subform.recordsource..
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 6240
Try:
Me.[sub1].Form.RecordSource = "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
LinkMasterFields/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_*****************@news02.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!recordsource = "somequery"

End sub

I've also tried variations of this Me.subforms.recordsource
and Forms!mainform.subform.recordsource..
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*********@SeeSig.Invalidwrote in message
news:44***********************@per-qv1-newsreader-01.iinet.net.au...
Try:
Me.[sub1].Form.RecordSource = "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
LinkMasterFields/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_*****************@news02.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!recordsource = "somequery"

End sub

I've also tried variations of this Me.subforms.recordsource
and Forms!mainform.subform.recordsource..
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
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...
25
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...
3
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...
4
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...
5
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...
0
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...
1
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...
6
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...
9
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...
1
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...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.