open form from list box

JonatABS

Registered User.
Local time
Yesterday, 21:01
Joined
Dec 16, 2002
Messages
114
Ok I got a working search list based on a query and it works like a charm. Heck I can search anything in any of the fields. Its awsome

However it does me no good if I cant double click on the record that I found and open up the main form that I can use to look at the information and edit it.

Help

The main form is a tabbed form by the way.

the search list based on the query is named SEARCHLIST
the form it needs to go to when I double click on an employeee I find and open up the form EMPLOYEEINFO.

Any help would be great. !!

Thanks Guys I know you have a solution for me.

Jon
 
Jon

The following example shows one way of doing this, there is probably better ones...

Code:
Private Sub lstSearchList_DblClick(Cancel As Integer)
On Error GoTo Err_lstSearchList_Dblclick

    Dim stDocName As String
    Dim stlinkcriteria As String
    
    stDocName = "frmBooks"
    
    stlinkcriteria = "[BookID]=" & Me![lstSearchList]
    DoCmd.OpenForm stDocName, , , stlinkcriteria

Exit_lstSearchList_Dblclick:
    Exit Sub

Err_lstSearchList_Dblclick:
    MsgBox Err.Description
    Resume Exit_lstSearchList_Dblclick
    
End Sub

This uses a list box called lstSearchList, and is opening the form named "frmBooks"

The list box contains the field BookID (hidden) and is used to find the related record in the frmbooks using the link criteria

I hope this gives you some idea

Graham
 
Cool thanks, That works

One problem
I have a tabbed form. I double click on the selection and it opens up an empty tabbed form.

This tabbed form is called EMPLOYEEINFO and the search list is named SEARCHLIST

what Do I need to do to modify this to make it work.
 
Jon

You will need to ensure that you have a corresponding field on the tabbed form that you are opening from the List Box.

I have attached a quick example of an Access 2K database showing this.

HTH

Graham
 

Attachments

Link with query?

Graham-

Your example hits home for me! I'm trying to link to a query, not a table. How would the linkcriteria look for a query?

in your example:
stLinkCriteria = "[BookID]=" & Me![lstSearchList]
DoCmd.OpenForm stDocName, , , stLinkCriteria

I would think it is more efficient to have the listbox link to query, which brings up a small recordset vs. running a filter against all records on a table. yes/no?

-stormin.
 

Users who are viewing this thread

Back
Top Bottom