1.3k Aufrufe
Gefragt in Datenbanken von
HIHO liebe community

ich habe ein neues problem... die idee ist folgende:
ich habe ein formular für neue aufträge, dort sollen zuständige mitarbeiter ausgewählt werden, die dann in einem textfeld angezeigt werden und beim speichern des datensatzes in ein textfeld der tabelle übergeben werden...
bsp: chk1 (text: SG) wird gecheckt, im textfeld würde beim aktualisieren (per knopfklick) SG stehen
sind nun zb. chk1 (text:SG) und chk2 (text:SK) gecheckt soll im textfeld SG,SK stehen...

Ich habe das ganze mühselig mittels microsoft code schon mit einem listenfeld gelöst, jedoch finde ich die variante mit checkboxen viel besser für den user...
leider bin ich kein code*Z* und habe das dank einfacher anleitung hinbekommen, hier aber trotzdem der code und vllt könnt ihr mir dann auch helfen, das ganze für checkboxen um zubauen...
mfg gast111


Option Compare Database
Option Explicit

Private Sub Form_Current()
Dim oItem As Variant
Dim bFound As Boolean
Dim sTemp As String
Dim sValue As String
Dim sChar As String
Dim iCount As Integer
Dim iListItemsCount As Integer

sTemp = Nz(Me.mySelections.Value, " ")
iListItemsCount = 0
bFound = False
iCount = 0

Call clearListBox

For iCount = 1 To Len(sTemp) + 1
sChar = Mid(sTemp, iCount, 1)
If StrComp(sChar, ",") = 0 Or iCount = Len(sTemp) + 1 Then
bFound = False
Do
If StrComp(Trim(Me!NamesList.ItemData(iListItemsCount)), Trim(sValue)) = 0 Then
Me!NamesList.Selected(iListItemsCount) = True
bFound = True
End If
iListItemsCount = iListItemsCount + 1
Loop Until bFound = True Or iListItemsCount = Me!NamesList.ListCount
sValue = ""
Else
sValue = sValue & sChar
End If
Next iCount
End Sub

Private Sub clearListBox()
Dim iCount As Integer

For iCount = 0 To Me!NamesList.ListCount
Me!NamesList.Selected(iCount) = False
Next iCount
End Sub

Private Sub testmultiselect_Click()
Dim oItem As Variant
Dim sTemp As String
Dim iCount As Integer

iCount = 0

If Me!NamesList.ItemsSelected.Count <> 0 Then
For Each oItem In Me!NamesList.ItemsSelected
If iCount = 0 Then
sTemp = sTemp & Me!NamesList.ItemData(oItem)
iCount = iCount + 1
Else
sTemp = sTemp & "," & Me!NamesList.ItemData(oItem)
iCount = iCount + 1
End If
Next oItem
Else
MsgBox "Nothing was selected from the list", vbInformation
Exit Sub 'Nothing was selected
End If

Me!mySelections.Value = sTemp
End Sub

Private Sub clrList_Click()
Call clearListBox
Me!mySelections.Value = Null
End Sub




[*][sup]
*Threadedit* 11.05.2009, 11:47:03
Admininfo: Artikel editiert. Siehe FAQ 2
[/sup]

1 Antwort

0 Punkte
Beantwortet von
sorry titel falsch - meinte natürlich checkbox statt combifeld -.-*
...