Double Click List Box

C

CJ

Hi Groupies:

I am trying to open another form when I double click an item in a listbox.
However, I keep getting a parameter error. I don't understand why I am
getting this error because the field on the form I am trying to open is
definitely called SKU Number. The good news is that the parameter shows that
it has the correct value selected but when I click OK the form opens up
empty.
Here is my code:

Private Sub lstTruckInventory_DblClick(Cancel As Integer)
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmInventory"

stLinkCriteria = "[SKU Number]= " & Me.lstTruckInventory.Column(0)
DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub


Could somebody please fix this for me?
 
D

Douglas J. Steele

Is SKU Number a text field? If so, you need quotes around the value:

stLinkCriteria = "[SKU Number]= '" & Me.lstTruckInventory.Column(0) & "'"

Exagerated for clarity, that's

stLinkCriteria = "[SKU Number]= ' " & Me.lstTruckInventory.Column(0) & " ' "
 
C

CJ

I had tried the quote thing but I obviously had not done it correctly.

Thanks a bunch Doug!

--
Thanks for taking the time!

CJ
---------------------------------------------------------
Know thyself, know thy limits....know thy newsgroups!
Douglas J. Steele said:
Is SKU Number a text field? If so, you need quotes around the value:

stLinkCriteria = "[SKU Number]= '" & Me.lstTruckInventory.Column(0) & "'"

Exagerated for clarity, that's

stLinkCriteria = "[SKU Number]= ' " & Me.lstTruckInventory.Column(0) & " '
"

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


CJ said:
Hi Groupies:

I am trying to open another form when I double click an item in a
listbox. However, I keep getting a parameter error. I don't understand
why I am getting this error because the field on the form I am trying to
open is definitely called SKU Number. The good news is that the parameter
shows that it has the correct value selected but when I click OK the form
opens up empty.
Here is my code:

Private Sub lstTruckInventory_DblClick(Cancel As Integer)
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmInventory"

stLinkCriteria = "[SKU Number]= " & Me.lstTruckInventory.Column(0)
DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub


Could somebody please fix this for me?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top