473,326 Members | 2,061 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,326 software developers and data experts.

Set Subform sourceobject and recordsource

I'm not sure why the following isn't working. The subform loads correctly,
but no data is displayed. I'm certain that there is data and I have checked
that the SQL statement does in fact return that data (checked by pasting the
statement into a new Access Query in the database window).

Me.FutureSubform.SourceObject = "FutureProjectionSubForm"
Me.FutureSubform.Form.RecordSource = "SELECT * FROM [TEMP_PROJECT_TABLE]"
Me.FutureSubform.Form.Requery

Is there something about the fact that I'm trying to set the recordsource of
the subform after it has loaded?

--
Message posted via http://www.accessmonster.com
Jan 19 '06 #1
9 24529
Robert, when you set the SourceObject of a subform control, Access has a go
at assigning what it thinks you want for the LinkMasterFields and
LinkChildFields properties. If the subform displays nothing, my guess would
be that it has got this wrong, and there are no related records based on
whatever it thinks are the link fields.

To test that idea, ask it to show you what it did after you assigned the
SourceObject:
Debug.Print Me.FutureSubform.LinkMasterFields
Debug.Print Me.FutureSubform.LinkChildFields

The solution is probably to set these 2 properties to the correct fields.

--
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.

"robert d via AccessMonster.com" <u6836@uwe> wrote in message
news:5a90a3385d51f@uwe...
I'm not sure why the following isn't working. The subform loads
correctly,
but no data is displayed. I'm certain that there is data and I have
checked
that the SQL statement does in fact return that data (checked by pasting
the
statement into a new Access Query in the database window).

Me.FutureSubform.SourceObject = "FutureProjectionSubForm"
Me.FutureSubform.Form.RecordSource = "SELECT * FROM [TEMP_PROJECT_TABLE]"
Me.FutureSubform.Form.Requery

Is there something about the fact that I'm trying to set the recordsource
of
the subform after it has loaded?

Jan 19 '06 #2
Allen, thanks for the response.

Everything is unbound. In the properties window for the subform control, the
"Link Child Fields" and Link Master Fields" properties are blank.

I must confess that I don't understand what these are or do, but at the same
time by setting the Recordsource of the subform, why doesn't it just fill
with the data from the SQL statement?

Thanks.

Allen Browne wrote:
Robert, when you set the SourceObject of a subform control, Access has a go
at assigning what it thinks you want for the LinkMasterFields and
LinkChildFields properties. If the subform displays nothing, my guess would
be that it has got this wrong, and there are no related records based on
whatever it thinks are the link fields.

To test that idea, ask it to show you what it did after you assigned the
SourceObject:
Debug.Print Me.FutureSubform.LinkMasterFields
Debug.Print Me.FutureSubform.LinkChildFields

The solution is probably to set these 2 properties to the correct fields.
I'm not sure why the following isn't working. The subform loads
correctly,

[quoted text clipped - 11 lines]
of
the subform after it has loaded?


--
Message posted via http://www.accessmonster.com
Jan 19 '06 #3
A subform is designed to show only those records that match the record in
the main form. The RecordSource of the subform is typically a table related
to the table that main form draws its records from. LinkMasterFields and
LinkChildFields define how the subform records "match" the main form record.
Even if these properties are blank at design time, you may find that they
are no longer blank after you assign the RecordSource of the subform.

--
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.

"robert d via AccessMonster.com" <u6836@uwe> wrote in message
news:5a9140c068953@uwe...
Allen, thanks for the response.

Everything is unbound. In the properties window for the subform control,
the
"Link Child Fields" and Link Master Fields" properties are blank.

I must confess that I don't understand what these are or do, but at the
same
time by setting the Recordsource of the subform, why doesn't it just fill
with the data from the SQL statement?

Thanks.

Allen Browne wrote:
Robert, when you set the SourceObject of a subform control, Access has a
go
at assigning what it thinks you want for the LinkMasterFields and
LinkChildFields properties. If the subform displays nothing, my guess
would
be that it has got this wrong, and there are no related records based on
whatever it thinks are the link fields.

To test that idea, ask it to show you what it did after you assigned the
SourceObject:
Debug.Print Me.FutureSubform.LinkMasterFields
Debug.Print Me.FutureSubform.LinkChildFields

The solution is probably to set these 2 properties to the correct fields.
I'm not sure why the following isn't working. The subform loads
correctly,

[quoted text clipped - 11 lines]
of
the subform after it has loaded?

Jan 19 '06 #4
O.K.

I got the values as you suggested, after setting the SourceObject, and they
are both blank. They stay blank even after the recordsource is set and the
requery line of code is executed.

Allen Browne wrote:
A subform is designed to show only those records that match the record in
the main form. The RecordSource of the subform is typically a table related
to the table that main form draws its records from. LinkMasterFields and
LinkChildFields define how the subform records "match" the main form record.
Even if these properties are blank at design time, you may find that they
are no longer blank after you assign the RecordSource of the subform.
Allen, thanks for the response.

[quoted text clipped - 29 lines]
of
the subform after it has loaded?


--
Message posted via http://www.accessmonster.com
Jan 19 '06 #5
If the LinkMasterFields and LinkChildFields are not limiting the subform's
records, I guess it is somethig else.

Open the subform itself in design view, and check its properties, For
example, if its Data Entry property is set to Yes, it will not show any
existing records.

Or is there are Filter applied? Try:
Debug.Print Me.FutureSubform.Form.Filter
Debug.Print Me.FutureSubform.Form.FilterOn

If not, ask it to show you the assigned RecordSource:
Debug.Print Me.FutureSubform.Form.RecordSource
(I am assuming it may be more complex than the example you posted
initially.)

--
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.

"robert d via AccessMonster.com" <u6836@uwe> wrote in message
news:5a91f4a7ee463@uwe...
O.K.

I got the values as you suggested, after setting the SourceObject, and
they
are both blank. They stay blank even after the recordsource is set and
the
requery line of code is executed.

Allen Browne wrote:
A subform is designed to show only those records that match the record in
the main form. The RecordSource of the subform is typically a table
related
to the table that main form draws its records from. LinkMasterFields and
LinkChildFields define how the subform records "match" the main form
record.
Even if these properties are blank at design time, you may find that they
are no longer blank after you assign the RecordSource of the subform.
Allen, thanks for the response.

[quoted text clipped - 29 lines]
> of
> the subform after it has loaded?

Jan 19 '06 #6
Nope. Data Entry is No. No filters are set. The RecordSource of the form
is shown as being equal to the SQL statement in my first post.

I put the Me.RecordSource statement for the subform in the load event of the
subform. Still nothing is populated. So out of frustration. I put a
listbox on the subform and, in the Form Load event of the subform, set it's
RowSource property to the SQL statement listed above.

The listbox is populated with the exact records I want! But I really wanted
to use a subform because I wanted to allow for easy "cell like" editing and
deleting.

Thanks for being patient with me. I still don't have a clue. It looks like
for some reason, the RecordSource of the form is not being set even though
there is clearly an SQL statement assigned to it.

Allen Browne wrote:
If the LinkMasterFields and LinkChildFields are not limiting the subform's
records, I guess it is somethig else.

Open the subform itself in design view, and check its properties, For
example, if its Data Entry property is set to Yes, it will not show any
existing records.

Or is there are Filter applied? Try:
Debug.Print Me.FutureSubform.Form.Filter
Debug.Print Me.FutureSubform.Form.FilterOn

If not, ask it to show you the assigned RecordSource:
Debug.Print Me.FutureSubform.Form.RecordSource
(I am assuming it may be more complex than the example you posted
initially.)
O.K.

[quoted text clipped - 18 lines]
>> of
>> the subform after it has loaded?


--
Message posted via http://www.accessmonster.com
Jan 19 '06 #7
Okay, I found my mistake and a stupid one it is at that.

The ControlSource of the textboxes on the subform (to be displayed in
continuous mode) was not set. Hence no data was displayed. Once set, data
is displayed as expected.

Thanks for your patience, Allen.

robert d wrote:
Nope. Data Entry is No. No filters are set. The RecordSource of the form
is shown as being equal to the SQL statement in my first post.

I put the Me.RecordSource statement for the subform in the load event of the
subform. Still nothing is populated. So out of frustration. I put a
listbox on the subform and, in the Form Load event of the subform, set it's
RowSource property to the SQL statement listed above.

The listbox is populated with the exact records I want! But I really wanted
to use a subform because I wanted to allow for easy "cell like" editing and
deleting.

Thanks for being patient with me. I still don't have a clue. It looks like
for some reason, the RecordSource of the form is not being set even though
there is clearly an SQL statement assigned to it.
If the LinkMasterFields and LinkChildFields are not limiting the subform's
records, I guess it is somethig else.

[quoted text clipped - 17 lines]
>>> of
>>> the subform after it has loaded?


--
Message posted via http://www.accessmonster.com
Jan 19 '06 #8
You could try moving the assignment of the RecordSource into the Open event
of the subform instead of its Load event. (The Requery is superfluous, so
you can drop that line.)

Your first paragraph implies that you verified the RecordSource property is
being correctly set, but I was not sure about that after your last
paragraph.

If the query statement really is that simple, then I fail to see why you are
assigning the property in the first place. Why not just save the form with
TEMP_PROJECT_TABLE as its RecordSource?

As always, you will want to uncheck the Name AutoCorrect boxes under:
Tools | Options | General
and then compact the database. That's one source of huge confusion to
Access.

--
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.

"robert d via AccessMonster.com" <u6836@uwe> wrote in message
news:5a924282e1f87@uwe...
Nope. Data Entry is No. No filters are set. The RecordSource of the
form
is shown as being equal to the SQL statement in my first post.

I put the Me.RecordSource statement for the subform in the load event of
the
subform. Still nothing is populated. So out of frustration. I put a
listbox on the subform and, in the Form Load event of the subform, set
it's
RowSource property to the SQL statement listed above.

The listbox is populated with the exact records I want! But I really
wanted
to use a subform because I wanted to allow for easy "cell like" editing
and
deleting.

Thanks for being patient with me. I still don't have a clue. It looks
like
for some reason, the RecordSource of the form is not being set even though
there is clearly an SQL statement assigned to it.

Allen Browne wrote:
If the LinkMasterFields and LinkChildFields are not limiting the subform's
records, I guess it is somethig else.

Open the subform itself in design view, and check its properties, For
example, if its Data Entry property is set to Yes, it will not show any
existing records.

Or is there are Filter applied? Try:
Debug.Print Me.FutureSubform.Form.Filter
Debug.Print Me.FutureSubform.Form.FilterOn

If not, ask it to show you the assigned RecordSource:
Debug.Print Me.FutureSubform.Form.RecordSource
(I am assuming it may be more complex than the example you posted
initially.)
O.K.

[quoted text clipped - 18 lines]
>>> of
>>> the subform after it has loaded?

Jan 19 '06 #9
Okay: that's solved. Good.

Thanks for posting the solution, in case someone else hits the same issue.

--
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.

"robert d via AccessMonster.com" <u6836@uwe> wrote in message
news:5a92791fa5eff@uwe...
Okay, I found my mistake and a stupid one it is at that.

The ControlSource of the textboxes on the subform (to be displayed in
continuous mode) was not set. Hence no data was displayed. Once set,
data
is displayed as expected.

Jan 19 '06 #10

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

Similar topics

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...
12
by: MLH | last post by:
I have created two forms: frmBrowseNegsMainform and frmBrowseNegsSubform. I put a subform control on the first of these. The SourceObject property for the subform control is, of course,...
4
by: Peter Bailey | last post by:
I have a subform that I dont want to have a recordsource initially as it is locking the table that is created dynamically. I want to connect to the table after the data has been written by another...
6
by: Tim Marshall | last post by:
Here's the situation. A form, frmSetUp, with a subform control called subExplain with a source object form frmSetUpSubDefineSides. The source object is a bound form, displaying a few records, no...
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...
5
by: (PeteCresswell) | last post by:
I've got a parent form and three subforms. Two of them work A-OK. For the third one, in the Immediate window: ----------------------------------------- ?Me.subDeal.Name subDeal ...
7
by: ApexData | last post by:
I am using the following code in my TabControl to manage subform loads. The code assigns the subForms SourceObject. - Do I also need code to DeAssign the SourceObject when leaving the Tab, I'm...
1
by: veteranwebdesign | last post by:
Hello, I have a main form. I want forms to open in a subform control box. What is the code for the option group to open the subforms in the control box. I didn't create subforms, I created...
19
by: postman | last post by:
I have a parent form bound to a recordsource and several controls are bound to fields in that recordsource. There are also several unbound controls that are used to display various data in a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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)...
1
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.