Doubleclick listbox

dcollins

Registered User.
Local time
Today, 21:16
Joined
Nov 24, 2003
Messages
30
I have a search form that populates a listbox based on the search criteria. I want to doubleclick on one item in the listbox and populate another form. I've used the code that I found here but it does not work for me. The form I am trying to poplulate an EnterAsset form and is based on a query so I am thinking that is my problem but I cannot find a solution. Below is my code. The AssetNum is the first column in the listbox. I've tried using [qryAssetTable].[AssetNum] but that doesn't work. Any ideas. The error message I get with this code is "the openform action was canceled"

Code:
Private Sub lstResults_DblClick(Cancel As Integer)

    DoCmd.OpenForm "frmEnterAssets", , , "[tblAsset].[AssetNum] = " & Me.lstResults.Column(0)

End Sub

Thanks
 
Okay, I got the openform to work and my form opens fine. But, the fields on the form do not populate with the selected record. I've tried numerous things and none seem to work. I've attached my db in hopes that someone can look at it and see what I am doing wrong.
Meanwhile, I'll plug away....
 

Attachments

Have a look at it now, I have made a copy of the form FrmEnterAssets and called it frmEnterAssets2.

If you run you search now and dbl click it (frmEnterAssets2) will open at the correct record. I have also changed cboAssetNum so that it will look up the records in this form. I have also changed the source for frmEnterAssets2 it is now called QryAssetTable2. The reason I made a copy and changed it is that I did not know what this want doing:

[Forms]![frmEnterAssets]![cboAssetNum]

This code of your is correct; problem was that you did not have AssetNum as a field in the frmEnterAssets. In mine you will see it in the top right hand corner (enabled = false---greyed out)



Code:
stLinkCriteria = "[AssetNum]=" & "'" & Me!lstResults.Column(0) & "'"
 
Last edited:
Thanks sooo much for your help. For some reason your db gave me "can find project or library" errors but I just applied everything you did to mine and it works great. The [Forms]![frmEnterAssets]![cboAssetNum] in my query was what filled in the fields from my combo box, but your way works too. Sorry my response took so long, other projects (and vacation!) came up and I had to set this aside. Again, thank you!
 

Users who are viewing this thread

Back
Top Bottom