|
Great thanks to all the helpful responses I've read! Recently using MS Access after a lengthy (7-10 years) away from the tool. I apologize for posting a question that for all intents & purposes appears to have been answered several times. Unfortunately, I've tried nearly a dozen approaches that seem to work for others on this board with similar (nearly identical in some cases) problems.
I would like to navigate through records on a subform based on the selection from a listbox. Id prefer to put the listbox is on the subform, but I've had the most progress putting it on the Main form.
Mainform data tblMaster (with tblMaster.idno as key)
Subform Data tblPupil (with tblPupil.idno as key and frnKeyMaster as frnKey to Master)
On the frmMaster, I have a listbox whose recordsource is a query of the tblPupil table where tblpupil.frnKeyMaster = frmMaster.idno
On UPdate of that listbox, I have this code:
Private Sub lstFindPupil_AfterUpdate()
Dim strSQL As String
strSQL = ""
strSQL = "SELECT tblPupil.* FROM tblPupil WHERE (((tblPupil.idno)=" & lstFindPupil & "));"
MsgBox strSQL
Me.subfrmPupils.Form.RecordSource = strSQL
Me.subfrmPupils.Form.Requery
End Sub
The subform requeries to a "new record", which is clearly not the desired result. further, the new record does not grab the IDNO from the frmMaster (which works when just adding records to the subfrm conventionally).
Thanks in advance for any new suggestions.
|