Open selected record

Birkofas

New member
Local time
Today, 16:07
Joined
Apr 29, 2008
Messages
8
In my form I have list box lstNames, subform sfrmDate and button PreviewReport, which opens all records in report rptNames. I need this report button open selected name from the list box with data from subform. I don't know how to write the code for this action. Can you help me please.
 
You may put these codes under the After Update Event of the lstNames list box. XYZID being the id in your name list.

Private Sub lstNames _AfterUpdate()
On Error GoTo Error_lstNames_AfterUpdate

If IsNull(Me.lstNames) Then GoTo Exit_lstNames_AfterUpdate
Me.RecordsetClone.FindFirst "XYZID = " & Me.lstNames
Me.Bookmark = Me.RecordsetClone.Bookmark
Me.EmpID = Me.lstNames

Exit_lstNames_AfterUpdate:
Exit Sub
Error_lstNames_AfterUpdate:
Msgbox Err.Description
Resume Exit_lstNames_AfterUpdate
End Sub

Each time you select a name in the name list, the sub form will show only data under that name. Put the open report button on the sub form and run report to show current record only - filter data to existing XYZID.

Hope this is what you want.

Mike
 

Users who are viewing this thread

Back
Top Bottom