Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open form with specific record based on List box selection 1

Status
Not open for further replies.

ScorpioX

MIS
Apr 30, 2003
63
US
Hi All,
I have a little issue. I am trying open a form, showing a specific record based on the selection in a list box.
The form I am opening is "frmWork_preview", which is opened by double clicking on a list box, named "List58". The List box is populated by "CNumber" in the Main form. I have it working to some extent. It does open the right form, but will not show the correct record. Anyone have any ideas?

Thanks,
ScorpioX
 
An easy way is to create a macro. Under the Action Column in the first cell put Echo. At the bottom under Action Arguments where it says Echo On put No.
In the next Action cell, put OpenForm. At the bottom, put in your formname, in the next cell the word View, leave Filter Name Blank,Where Condition would look like this -
[CNumber]=[Forms]![FrmWork_Preview]![List58], leave Data Mode blank, Window is Normal.
Save the macro and place the name on the On Dbl Click event of the listbox's property.

Make sure your Listbox is bound to CNumber.
 
Oops. the Where condition is wrong. I put the name of the form you're opening as the form you're coming from. It should be:
[CNumber]=[Forms]![FormnameOfListbox]![List58]
 
Hi All,
Thank you for your replies. I was able to get it working though, using part of pbaldy's code in mine. I have included the working code below.
Code:
On Error GoTo Err_List58_DblClick
    Dim stDocName As String
    Dim stLinkCriteria As String
    stDocName = "frmWork_preview"
    stLinkCriteria = "[Work_#]=" & Me![List58]
    DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_List58_DblClick:
    Exit Sub
Err_List58_DblClick:
    MsgBox Err.Description
    Resume Exit_List58_DblClick
End Sub

Thanks again,
ScorpioX
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top