Requery

G

Guest

I have a form with a combo box which users use to select records and display
the information on the form. No prob here
Also displayed is a subform which also displays certain fields from other
records that are related to the record displayed on the main form. No probs
here.
I also have a command button displayed next to each record on the subform,
this button when clicked places the record in view on the main form.
My problem is that when this happens the form will only display the record
selected by the command button and to view any other records through the main
form I have to close it and re-open it, at which point everything works fine
again.
I have tried various versions of the Requery command. I have initially
inserted a command button on the main form to do the requery, until I get the
code right, at which point I will move the code to the appropriate event to
automate the process.
I have tried

Version 1
Me.Requery

Version 2
Combo22.Requery (Combo22 is the name of the Combo on the main form)

Version 3
forms![Sample Results].Requery ([Sample Results] is the name of the
main form

Can anyone help with my problem.

Many thanks

Richard
 
G

Guest

What is the code under the button on your subform?

Are you setting a filter or re-opening the form with Criteria or OpenArgs?
If you are doing any of the above, you have restricted the recordset of the
form to one record. To view others, you will have to reset the fielter or
re-open the form.

A more suitable solution may be to find the record in the main form's
recordset and set a bookmark. That will just move your main form to the
selected record without filtering or otherwise limiting the underlying data.

If you supply your code for the button, it will make it easier to provide a
solution for you.

Steve
 
G

Guest

Below is the code under the command button on the subform

thanks for the help

Private Sub Command7_Click()
On Error GoTo Err_Command7_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Sample Results"

stLinkCriteria = "[Our Sample Number]=" & Me![Our Sample Number]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command7_Click:
Exit Sub

Err_Command7_Click:
MsgBox Err.Description
Resume Exit_Command7_Click


End Sub

SteveM said:
What is the code under the button on your subform?

Are you setting a filter or re-opening the form with Criteria or OpenArgs?
If you are doing any of the above, you have restricted the recordset of the
form to one record. To view others, you will have to reset the fielter or
re-open the form.

A more suitable solution may be to find the record in the main form's
recordset and set a bookmark. That will just move your main form to the
selected record without filtering or otherwise limiting the underlying data.

If you supply your code for the button, it will make it easier to provide a
solution for you.

Steve

richard said:
I have a form with a combo box which users use to select records and display
the information on the form. No prob here
Also displayed is a subform which also displays certain fields from other
records that are related to the record displayed on the main form. No probs
here.
I also have a command button displayed next to each record on the subform,
this button when clicked places the record in view on the main form.
My problem is that when this happens the form will only display the record
selected by the command button and to view any other records through the main
form I have to close it and re-open it, at which point everything works fine
again.
I have tried various versions of the Requery command. I have initially
inserted a command button on the main form to do the requery, until I get the
code right, at which point I will move the code to the appropriate event to
automate the process.
I have tried

Version 1
Me.Requery

Version 2
Combo22.Requery (Combo22 is the name of the Combo on the main form)

Version 3
forms![Sample Results].Requery ([Sample Results] is the name of the
main form

Can anyone help with my problem.

Many thanks

Richard
 

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