Refreshing subform - Query changed

H

Harry

Hi All,

I have a form with some buttons. The buttons do change a query (Q-PCcontent)
by a sql statement. the variable in the statement is the TAG of the button.
pressing the button MyPC the query-data changes to contain only data
belonging to my computer. Pressing another button the querycontent changes
accordingly.
On the form I have placed a (continious form)subform (without linking
master/child fields).
On opening the master form the subform does display all wanted records from
the query. However after pressing a button (the query content changes, I've
checked it)
the subform will not change.
Using a refreshbutton on the subform, vbacode behind button
[Me.PC_Content_subform.Requery] does not help.
Who can help me?

kind regards,
 
K

kingston via AccessMonster.com

Exactly how do the buttons change the query and how is the subform Record
Source set? Is there an actual visual query object and is the subform bound
to it? Use an SQL statement instead to specify the subform's Record Source:

Me.PC_Content_subform.Form.RecordSource = NewSQLStatement
Hi All,

I have a form with some buttons. The buttons do change a query (Q-PCcontent)
by a sql statement. the variable in the statement is the TAG of the button.
pressing the button MyPC the query-data changes to contain only data
belonging to my computer. Pressing another button the querycontent changes
accordingly.
On the form I have placed a (continious form)subform (without linking
master/child fields).
On opening the master form the subform does display all wanted records from
the query. However after pressing a button (the query content changes, I've
checked it)
the subform will not change.
Using a refreshbutton on the subform, vbacode behind button
[Me.PC_Content_subform.Requery] does not help.
Who can help me?

kind regards,
 
H

Harry

Hi Kingston?

Please find below the vba of the button with the relation to the query.
Private Sub BtnPC1_Click()
Me.TAGID = Me.BtnPC1.TAG
QCONTENTPC
End Sub
Function QCONTENTPC()
sSQLField = "(((Software." & TAGID & ") = Yes));"
sSQL = "SELECT Software.*, Disc.DiscName FROM Software INNER JOIN Disc ON
Software.DiscID = Disc.DiscID WHERE" & sSQLField
CurrentDb.QueryDefs("Q-ContentPC").SQL = sSQL
End Function

The subform itself is bound to the query Q-ContentPC.

Regards,
Harry
kingston via AccessMonster.com said:
Exactly how do the buttons change the query and how is the subform Record
Source set? Is there an actual visual query object and is the subform bound
to it? Use an SQL statement instead to specify the subform's Record Source:

Me.PC_Content_subform.Form.RecordSource = NewSQLStatement
Hi All,

I have a form with some buttons. The buttons do change a query (Q-PCcontent)
by a sql statement. the variable in the statement is the TAG of the button.
pressing the button MyPC the query-data changes to contain only data
belonging to my computer. Pressing another button the querycontent changes
accordingly.
On the form I have placed a (continious form)subform (without linking
master/child fields).
On opening the master form the subform does display all wanted records from
the query. However after pressing a button (the query content changes, I've
checked it)
the subform will not change.
Using a refreshbutton on the subform, vbacode behind button
[Me.PC_Content_subform.Requery] does not help.
Who can help me?

kind regards,
 
K

kingston via AccessMonster.com

Hi Harry,

when the subform object loads, an instance of the underlying query is
attached (the query's definition AT THAT TIME is used to construct the
subform). The query object itself is not bound to the subform. So changing
the query object will not change the subform unless you also unload the
subform and reload it. In addition, you can directly alter the subform's
RecordSource as I demonstrated in my previous post. I think it's much easier
unless you need to alter the visual query object. hth

Kingston
Hi Kingston?

Please find below the vba of the button with the relation to the query.
Private Sub BtnPC1_Click()
Me.TAGID = Me.BtnPC1.TAG
QCONTENTPC
End Sub
Function QCONTENTPC()
sSQLField = "(((Software." & TAGID & ") = Yes));"
sSQL = "SELECT Software.*, Disc.DiscName FROM Software INNER JOIN Disc ON
Software.DiscID = Disc.DiscID WHERE" & sSQLField
CurrentDb.QueryDefs("Q-ContentPC").SQL = sSQL
End Function

The subform itself is bound to the query Q-ContentPC.

Regards,
Harry
Exactly how do the buttons change the query and how is the subform Record
Source set? Is there an actual visual query object and is the subform bound
[quoted text clipped - 20 lines]
 
H

Harry

Hi Kingston,

Thanks for your help.
The vba me.subfom.requery does unfortunately not help me out.
you mention:
"In addition, you can directly alter the subform's
RecordSource as I demonstrated in my previous post. I think it's much easier
unless you need to alter the visual query object. "

This would be of great help, however browsing the forum I could not find
this post.
can you point me to it?

greetings,
Harry

kingston via AccessMonster.com said:
Hi Harry,

when the subform object loads, an instance of the underlying query is
attached (the query's definition AT THAT TIME is used to construct the
subform). The query object itself is not bound to the subform. So changing
the query object will not change the subform unless you also unload the
subform and reload it. In addition, you can directly alter the subform's
RecordSource as I demonstrated in my previous post. I think it's much easier
unless you need to alter the visual query object. hth

Kingston
Hi Kingston?

Please find below the vba of the button with the relation to the query.
Private Sub BtnPC1_Click()
Me.TAGID = Me.BtnPC1.TAG
QCONTENTPC
End Sub
Function QCONTENTPC()
sSQLField = "(((Software." & TAGID & ") = Yes));"
sSQL = "SELECT Software.*, Disc.DiscName FROM Software INNER JOIN Disc ON
Software.DiscID = Disc.DiscID WHERE" & sSQLField
CurrentDb.QueryDefs("Q-ContentPC").SQL = sSQL
End Function

The subform itself is bound to the query Q-ContentPC.

Regards,
Harry
Exactly how do the buttons change the query and how is the subform Record
Source set? Is there an actual visual query object and is the subform bound
[quoted text clipped - 20 lines]
kind regards,
 
K

kingston via AccessMonster.com

Hi Harry,

what forum are you using? I'm curious because I see a lot of postings that I
suspect are coming from somewhere other than accessmonster.com but I don't
know where. Anyway, use something like the following VBA statement to change
the subform (triggered by on an event from the main form):

Me.PC_Content_subform.Form.RecordSource = NewSQLStatement

NewSQLStatement would be something like "SELECT ... FROM ... WHERE ..."
Hi Kingston,

Thanks for your help.
The vba me.subfom.requery does unfortunately not help me out.
you mention:
"In addition, you can directly alter the subform's
RecordSource as I demonstrated in my previous post. I think it's much easier
unless you need to alter the visual query object. "

This would be of great help, however browsing the forum I could not find
this post.
can you point me to it?

greetings,
Harry
Hi Harry,
[quoted text clipped - 32 lines]
 
H

Harry

Hi Kingston,

Thanks it worked out.
using: Me.PC_Content_subform.Form.RecordSource = sSQL

I am using the forum www.microsoft.com/community.
It is visible that you are using AccessMonster as it shows within your
replies.

Thanks again,
Greetings,
Harry

kingston via AccessMonster.com said:
Hi Harry,

what forum are you using? I'm curious because I see a lot of postings that I
suspect are coming from somewhere other than accessmonster.com but I don't
know where. Anyway, use something like the following VBA statement to change
the subform (triggered by on an event from the main form):

Me.PC_Content_subform.Form.RecordSource = NewSQLStatement

NewSQLStatement would be something like "SELECT ... FROM ... WHERE ..."
Hi Kingston,

Thanks for your help.
The vba me.subfom.requery does unfortunately not help me out.
you mention:
"In addition, you can directly alter the subform's
RecordSource as I demonstrated in my previous post. I think it's much easier
unless you need to alter the visual query object. "

This would be of great help, however browsing the forum I could not find
this post.
can you point me to it?

greetings,
Harry
Hi Harry,
[quoted text clipped - 32 lines]
kind regards,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top