|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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 !!! |
|
#2
|
|||
|
|||
|
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 |
|
#3
|
|||
|
|||
|
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 !! |
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > Tricky question |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|