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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I open a form by listbox selection?

Status
Not open for further replies.

wabtrainer

IS-IT--Management
Feb 4, 2002
66
GB
I know there is probably an easy answer to this but I am struggling (cant see the wood for the trees!)

U have a form open that populates the listbox from a stored query.

When I select a row in the listbox I want it to open a new form opened at that selected record.
At the moment it jus opens the form at the first record.

Private Sub LstFindings_Click()
Me.Visible = False
DoCmd.OpenForm "frmQIPPriceAll"
End Sub

I tried various things to the docmd statement but get errors.
Any ideas????????????


If you want to be a bear:
Be a Grizzly!
 
You can use the WhereCondition parameter of the DoCmd like so. It is not clear what the value in the list box is. I assume it is a field on the second form. If you want to go to a specific record, you should be using a key field. I am going to pretend that you list box has the recordid in it. Then we would say...

Code:
Private Sub LstFindings_Click()
    Me.Visible = False
    DoCmd.OpenForm "frmQIPPriceAll", acNormal, , "RECORDID = " & Me.ListBoxName
End Sub



ProDev, MS Access Applications
Visit me at ==>
May God bless you beyond your imagination!!!
 
Got there in the end:

Private Sub LstFindings_Click()
Dim strCriteria As String
Dim txtPartNo As String

txtPartNo = Forms![frmIPPriceHistory]![LstFindings].Column(1)
strCriteria = "[PartNo]= '" & Me.LstFindings & "'"
DoCmd.OpenForm "frmQIPPriceAll", , , strCriteria
Me.Visible = False


End Sub

Hand to change the bound column to (1) otherwise got an error!

Thanks for your help.




If you want to be a bear:
Be a Grizzly!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top