List Box Selecting

aingram

Registered User.
Local time
Today, 13:08
Joined
Jun 20, 2005
Messages
29
Hi All,

I have a database that has route lists for drivers,
I have a combo box that lets the user select a route and a timescale
and with that data it populates the list box,,,

The list box displays
-- Route -- Period -- Month
eg -- 1 -- 6 montly -- jan, jul

Now then,
I need the database to be able to double click on the list box and for it to preview a reoprt,
but i can work out how to set querry criteria from that command

Code:
Private Sub LstBox_DblClick(Cancel As Integer)
On Error GoTo Err_LstBox_DblClick

    Dim stDocName As String

    stDocName = "Rpt_Route_MAIN"
    DoCmd.OpenReport stDocName, acPreview

Exit_LstBox_DblClick:
    Exit Sub

Err_LstBox_DblClick:
    MsgBox Err.Description
    Resume Exit_LstBox_DblClick
    
End Sub
I know i can use this to open the report but its not relevent to what has been clicked on

I've got a query set up that supports the report the two fields that need to be trasmited to the criteria of the query are :
1. Route
2. Timescale

Help Please


Thanking you in advance
 
You have to put a condition.

Code:
Private Sub LstBox_DblClick(Cancel As Integer)
On Error GoTo Err_LstBox_DblClick

    Dim stDocName As String

    stDocName = "Rpt_Route_MAIN"
    stLinkCriteria = "[field you want to match]=" & Me![text box you want to match with the field]   
    DoCmd.OpenReport stDocName, acViewPreview, , stLinkCriteria

    

Exit_LstBox_DblClick:
    Exit Sub

Err_LstBox_DblClick:
    MsgBox Err.Description
    Resume Exit_LstBox_DblClick
    
End Sub

I think this should give you a good result.

Le
 

Users who are viewing this thread

Back
Top Bottom