requery a subform

Eric the Viking

Registered User.
Local time
Today, 00:14
Joined
Sep 20, 2012
Messages
70
Dear All

More help needed if there is a solution.

I have a form with a list box on it. When I select a record it opens another form with the full record using the OnClick event with the following code:

Private Sub ListPts_Click()
On Error GoTo Err_ListPts_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frm-Update patient details"

stLinkCriteria = "[Patient number]=" & Me![ListPts]
DoCmd.OpenForm stDocName, , , stLinkCriteria


Dim setListPtsHeight As Integer

setHeight = 275
Me.ListPts.Height = setHeight
ListPts.RowSource = ""

Exit_ListPts_Click:
Exit Sub

Err_ListPts_Click:
MsgBox Err.Description
Resume Exit_ListPts_Click

End Sub

The subform lists all the recently viewed full records. What I want to try and get to happen is to add a line of code in the list box OnClick event that requeries the subform to pick up the record I have just opened with the list box OnClick event.

I have tried putting this code in at various points:

Forms![Find Patients]![frm-LastViewed].Requery

(Find Patients is the main form and frm-LastViewed the subform) but cant get the outcome I am looking for.

Any ideas?

Regards

Eric
 
You

1. Need to refer to the subform CONTROL (control on the parent form which houses/displays the subform) and NOT the subform name itself unless both are exactly the same.

2. If your subform control is named the same as the subform (frm-LastViewed) then you sould be able to use what you put so I'm assuming that it is not the same.
 
Thanks for your reply

The subform name is frm-LastViewed

Appreciate the naming is screwy but we started this with no access knowledge and learning the hard way I guess having never constructed a data base before

What we are trying to do is fine tuning for a relatively simple data base

Just not sure where to put it in the OnClick event for the list box as where ever I put it the desired result doesnt seem to follow.

Is there any other code I should put before or after?

Regards

Eric
 
The control which has the link child and master fields options shows:

Name frm-LastViewed
Source Object frm-LastViewed

ie the same as the form frm-LastViewed which as originally constructed as a standalone form opened by a button on a main form although this is no longer the case.
 
Try it this way and see if that helps:

Forms("Find Patients").Controls("frm-LastViewed").Form.Requery

If not, perhaps it is the dash in the form name that is a problem. If you still can't get it, maybe uploading it here (with fake data) so we can check it out would be in order.
 

Users who are viewing this thread

Back
Top Bottom