Updating main form from a subform

G

Guest

I have a subform which is a datasheet. When a user clicks on a row in the
datasheet I want the record on the main form to update and display those
details.

If I have the following code executing on an on_click event I get an out of
stack error:-

Private Sub pRiA_Enter()

Forms![frmrecords]![txtFilterPlaceHolder] = pRiA
DoCmd.Requery (qryUpdaterecords)

End Sub

txtFilterPlaceHolder is a hidden field on the main form from which the query
gets the value for the criteria.

I have tried a couple of other ways but nothing seems to work. I tried
setting the focus to the txtFilterPlaceHolder field and then executing the
requery from there on the got_focus event but I get an error saying cannot
set focus.


Any help would be hugely appreciated!

Antony
 
G

Guest

I have a subform which is a datasheet. When a user clicks on a row in the
datasheet I want the record on the main form to update and display those
details.

Why? What are you trying to achieve?
 
G

Guest

The datasheet subform allows the user to apply a variety of sorts to the data
based on up to 4 fields.

The main form then displays the full record.

Not how I would have done it but working under instruction .............
 
T

tina

try

Forms![frmrecords]![txtFilterPlaceHolder] = Me!pRiA
Forms![frmrecords].Requery

or, alternately

Me.Parent!txtFilterPlaceHolder = Me!pRiA
Me.Parent.Requery

hth
 
G

Guest

Hi Tina

Thanks! That worked perfectly!

AJ



tina said:
try

Forms![frmrecords]![txtFilterPlaceHolder] = Me!pRiA
Forms![frmrecords].Requery

or, alternately

Me.Parent!txtFilterPlaceHolder = Me!pRiA
Me.Parent.Requery

hth


ajpsa said:
I have a subform which is a datasheet. When a user clicks on a row in the
datasheet I want the record on the main form to update and display those
details.

If I have the following code executing on an on_click event I get an out of
stack error:-

Private Sub pRiA_Enter()

Forms![frmrecords]![txtFilterPlaceHolder] = pRiA
DoCmd.Requery (qryUpdaterecords)

End Sub

txtFilterPlaceHolder is a hidden field on the main form from which the query
gets the value for the criteria.

I have tried a couple of other ways but nothing seems to work. I tried
setting the focus to the txtFilterPlaceHolder field and then executing the
requery from there on the got_focus event but I get an error saying cannot
set focus.


Any help would be hugely appreciated!

Antony
 
T

tina

you're welcome :)


ajpsa said:
Hi Tina

Thanks! That worked perfectly!

AJ



tina said:
try

Forms![frmrecords]![txtFilterPlaceHolder] = Me!pRiA
Forms![frmrecords].Requery

or, alternately

Me.Parent!txtFilterPlaceHolder = Me!pRiA
Me.Parent.Requery

hth


ajpsa said:
I have a subform which is a datasheet. When a user clicks on a row in the
datasheet I want the record on the main form to update and display those
details.

If I have the following code executing on an on_click event I get an
out
of
stack error:-

Private Sub pRiA_Enter()

Forms![frmrecords]![txtFilterPlaceHolder] = pRiA
DoCmd.Requery (qryUpdaterecords)

End Sub

txtFilterPlaceHolder is a hidden field on the main form from which the query
gets the value for the criteria.

I have tried a couple of other ways but nothing seems to work. I tried
setting the focus to the txtFilterPlaceHolder field and then executing the
requery from there on the got_focus event but I get an error saying cannot
set focus.


Any help would be hugely appreciated!

Antony
 

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