i am trying to creat an address book similar to the one in outlook express. The setup on the main address book form is this:
1. One list box that holds the email addresses. (lstEmail)
2. One list box for "To:" (ToBox)
3. One command button that moves the email address
from "lstEmail" to "ToBox" without removing it from the first list box. (CmdTo)
if you look at the
4. One command button that opens a data entry form for new contacts. (CmdNew)
in outlook express, if you click on the "To:" label in front of where you would type the email address when composing a new email you can see what i mean.
well, the jist of the problem is that i can't get the email address from the first list box (lstEmail) to go over to the second (ToBox). i got the following code from microsoft but it doesn't seem to work. i always receive "Run-time error 438: Object doesn't support this property of method".
This is the code behind the button to move the email address:
Private Sub CmdTo_Click()
MoveSingleItem "lstEmail", "ToBox"
End Sub
This is the sub routine called above:
Sub MoveSingleItem(strSourceControl As String, strTargetControl As String)
Dim strItem As String
Dim intColumnCount As Integer
For intColumnCount = 0 To Me.Controls(strSourceControl).ColumnCount - 1
strItem = strItem & Me.Controls(strSourceControl).column(intColumnCount) & ";"
Next
strItem = Left(strItem, Len(strItem) - 1)
'Check the length to make sure something is selected
If Len(strItem) > 0 Then
Me.Controls(strTargetControl).AddItem strItem '<---this is the line that is giving me trouble.
Me.Controls(strSourceControl).RemoveItem Me.Controls(strSourceControl).ListIndex
Else
MsgBox "Please select an item to move."
End If
End Sub
1. One list box that holds the email addresses. (lstEmail)
2. One list box for "To:" (ToBox)
3. One command button that moves the email address
from "lstEmail" to "ToBox" without removing it from the first list box. (CmdTo)
if you look at the
4. One command button that opens a data entry form for new contacts. (CmdNew)
in outlook express, if you click on the "To:" label in front of where you would type the email address when composing a new email you can see what i mean.
well, the jist of the problem is that i can't get the email address from the first list box (lstEmail) to go over to the second (ToBox). i got the following code from microsoft but it doesn't seem to work. i always receive "Run-time error 438: Object doesn't support this property of method".
This is the code behind the button to move the email address:
Private Sub CmdTo_Click()
MoveSingleItem "lstEmail", "ToBox"
End Sub
This is the sub routine called above:
Sub MoveSingleItem(strSourceControl As String, strTargetControl As String)
Dim strItem As String
Dim intColumnCount As Integer
For intColumnCount = 0 To Me.Controls(strSourceControl).ColumnCount - 1
strItem = strItem & Me.Controls(strSourceControl).column(intColumnCount) & ";"
Next
strItem = Left(strItem, Len(strItem) - 1)
'Check the length to make sure something is selected
If Len(strItem) > 0 Then
Me.Controls(strTargetControl).AddItem strItem '<---this is the line that is giving me trouble.
Me.Controls(strSourceControl).RemoveItem Me.Controls(strSourceControl).ListIndex
Else
MsgBox "Please select an item to move."
End If
End Sub