Hi there, 6 months ago i never touched access, now im using it and getting in deeper its becoming a challenge and access is winning at the moment.
I have read through alot of these threads that are very interesting and incorparated many of my findings in my database. however i'm stuck
What i want to do is from a multiple select list box is be able to select people from a table " Members" and display as well as have them added via double click or a command button to a subform on my main form. These people are the reciepients of documents that are relevant to the each record. It is a historical log of people that this information has been given to.
I had some code happening but since wrestling with it have lost what functionality i had. Can this be done with macros or is code the most viable option,
If this means anything to anyone, your advise and suggestions would be invaluable. I am going to learn this VBA stuff, any recommended easy reading books would also be much appreciated.
thanks in advance
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
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 Send_to_RX_table_Click()
On Error GoTo Err_Send_to_RX_table_Click
DoCmd.GoToRecord , , acNewRec
Exit_Send_to_RX_table_Click:
Exit Sub
Err_Send_to_RX_table_Click:
MsgBox Err.Description
Resume Exit_Send_to_RX_table_Click
End Sub
I have read through alot of these threads that are very interesting and incorparated many of my findings in my database. however i'm stuck
What i want to do is from a multiple select list box is be able to select people from a table " Members" and display as well as have them added via double click or a command button to a subform on my main form. These people are the reciepients of documents that are relevant to the each record. It is a historical log of people that this information has been given to.
I had some code happening but since wrestling with it have lost what functionality i had. Can this be done with macros or is code the most viable option,
If this means anything to anyone, your advise and suggestions would be invaluable. I am going to learn this VBA stuff, any recommended easy reading books would also be much appreciated.
thanks in advance
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
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 Send_to_RX_table_Click()
On Error GoTo Err_Send_to_RX_table_Click
DoCmd.GoToRecord , , acNewRec
Exit_Send_to_RX_table_Click:
Exit Sub
Err_Send_to_RX_table_Click:
MsgBox Err.Description
Resume Exit_Send_to_RX_table_Click
End Sub