Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / March 2005

Tip: Looking for answers? Try searching our database.

listbox ?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
chris - 24 Mar 2005 17:31 GMT
I am having a prblem with this script. the itemselected returns what appears
to me t
as the position of the item in the listbox i.e. 1,2,3 opposed to the values
i need although the display correctly in the listbox.

Private Sub Command24_Click()

Dim varItem As Variant
Dim strSql As String
Dim strIn As String

strSql = "INSERT INTO testing ( ID, DESCRIPTION, COMMODITY_CODE ) SELECT
dbo_PART.ID, dbo_PART.DESCRIPTION, dbo_PART.COMMODITY_CODE FROM dbo_PART
where commidty_code IN ("
'build list
For Each varItem In Me.COMMODITY_CODE_LISTBOX.ItemsSelected

  strIn = strIn & varItem & ","
Next varItem

'remove trailing comma
strIn = Left(strIn, Len(strIn) - 1)

strSql = strSql & strIn & ")"

End Sub
Dirk Goldgar - 24 Mar 2005 19:24 GMT
> I am having a prblem with this script. the itemselected returns what
> appears to me t
[quoted text clipped - 22 lines]
>
> End Sub

ItemsSelected returns a collection of row numbers (in the list), not the
values in the list for those rows.  Try this:

   With Me.COMMODITY_CODE_LISTBOX
       For Each varItem In .ItemsSelected
           strIn = strIn & .ItemData(varItem) & ","
       Next varItem
   End With

Signature

Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.