MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!
  #1  
Old March 20th, 2004, 07:36 PM
BratCat2 BratCat2 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 20 BratCat2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Tricky question

One Listbox

Need to get items from Listbox (which has different values on each line and is multiselect) to a field in my database.

This loads my selections to the Listbox and works.
Public values As Variant

Dim i As Integer
values = Split(ListView1.SelectedItem, vbCrLf)
For i = LBound(values) To UBound(values)
List1.AddItem values(i)
Next i

Command button to copy data to access field
Adodc1.Recordset.Fields(5).Value = values(i)

Access will only accept the first item in the field, even if I do a multiselect.

THX !!!

Reply With Quote
  #2  
Old March 21st, 2004, 02:19 AM
johan degraeve johan degraeve is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 9 johan degraeve User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
you have to make a string with semicolons

Tried this also once. Works with a string separated with semicolons, be sure to make the string with the dependent column data only. Because of the insureness of this I made a new table where the values are stored. It looks like this:

checkus
Set cnn1 = New ADODB.Connection
cnn1.ConnectionString = "driver={SQL Server};" & _
"server=" & cnstr

blablabla ... connect to the server with an sql command that returns the values for a certain column in the listbox


a = .RecordCount
If a = 0 Then GoTo new
.MoveLast
a = .RecordCount
.MoveFirst
Do Until .EOF = -1
X = !M_bloknr

'X is the value

For intCurrentRow = 0 To ctlsource.ListCount - 1
'Debug.Print X: Debug.Print ctlSource.ItemData(intCurrentRow)

'here you make the row selected, to do it in the opposite way t.i. to save the values, just do the opposite: read all the values and store them into records or into one record, separated with a semicolon


If Val(X) = Val(ctlsource.ItemData(intCurrentRow)) Then
ctlsource.Selected(intCurrentRow) = -1
End If
Next intCurrentRow

Do Until !M_bloknr <> X
.MoveNext
If .EOF = -1 Then Exit Sub
Loop
Loop

End With
Exit Sub

Reply With Quote
  #3  
Old March 21st, 2004, 11:38 AM
BratCat2 BratCat2 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 20 BratCat2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thank you

Is the last function listed already the opposite way ?

If Val(X) = Val(List1.ItemData(intCurrentRow)) Then
List1.Selected(intCurrentRow) = -1
End If
Next intCurrentRow

I added my List1 to the code is this correct ?

THX !!

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > Tricky question


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway