JChandler22
Registered User.
- Local time
- Today, 17:03
- Joined
- Jul 24, 2007
- Messages
- 52
I'm trying to add two linked list boxes to the 2nd tab (labeled "Program Interest") of my main form, which is called Contacts. I'll attach the db here:
View attachment db3.zip
I've formed the list boxes, as well as the control boxes between them, but the control buttons don't seem to work at all. The code for the so-called "add" button is:
and for the "remove" button:
I've double checked the name of the list boxes and combed through the code to try to figure it out, but to no avail - admittedly, I'm certainly no VBA expert when it comes to Access.
If someone would kindly take a look and see if they might be able to offer any suggestions or point me in the right direction, I would greatly appreciate it!
Thanks,
JChandler
View attachment db3.zip
I've formed the list boxes, as well as the control boxes between them, but the control buttons don't seem to work at all. The code for the so-called "add" button is:
Code:
Private Sub addBtn5_Click()
Dim ProgListCounter As Integer, ProgCurrentCounter As Integer
Dim ProgListItems As Integer, ProgCurrentItems As Integer
Dim ListStr As String, FoundInList As Integer
ProgListItems = [ProgAvailable].ListCount - 1
ProgCurrentItems = [ProgSelected].ListCount - 1
For ProgListCounter = 0 To ProgListItems
If [ProgAvailable].Selected(ProgListCounter) = True Then
If IsNull([ProgSelected].RowSource) Then
ListStr = [ProgAvailable].Column(0, ProgListCounter) & ";"
[ProgSelected].RowSource = ListStr
Else
FoundInList = False
For ProgCurrentCounter = 0 To ProgCurrentItems
If [ProgSelected].Column(0, ProgCurrentCounter) = [ProgAvailable].Column(0, ProgListCounter) Then
FoundInList = True
End If
Next ProgCurrentCounter
If Not FoundInList Then
ListStr = [ProgSelected].RowSource & [ProgAvailable].Column(0, ProgListCounter) & ";"
[ProgSelected].RowSource = ""
[ProgSelected].RowSource = ListStr
End If
End If
End If
Next ProgListCounter
End Sub
and for the "remove" button:
Code:
Private Sub remove_btn_Click()
Dim ListStr As String
Dim ProgCurrentItems As Integer, ProgCurrentCounter As Integer
Dim ProgListItems As Integer
ProgListItems = [ProgSelected].ListCount - 1
ListStr = ""
For ProgCurrentCounter = 0 To ProgListItems
If [ProgSelected].Selected(ProgCurrentCounter) = False Then
ListStr = ListStr & [ProgSelected].Column(0, ProgCurrentCounter) & ";"
End If
Next ProgCurrentCounter
[ProgSelected].RowSource = ""
[ProgSelected].RowSource = ListStr
End Sub
I've double checked the name of the list boxes and combed through the code to try to figure it out, but to no avail - admittedly, I'm certainly no VBA expert when it comes to Access.
If someone would kindly take a look and see if they might be able to offer any suggestions or point me in the right direction, I would greatly appreciate it!
Thanks,
JChandler