Error on VBA

Herkatus

Registered User.
Local time
Today, 01:01
Joined
Jul 17, 2009
Messages
16
Hello!

I have a financial database which I'm using to do bank account reconciliations.
I'm trying to build a form which only has 4 objects: a ListBox, a TextBox and 2 buttons.
The purpose of this form is to retrieve multi-selection items from the ListBox in the TextBox seperated by a comma, in order to use a query with multiple filters.

I went to http://support.microsoft.com/Default.aspx?scid=kb;en-us;827423&x=13&y=10 but I've stumbled across an error on VBA.

I tried only with
Code:
Private Sub clrList_Click()
End Sub
but everytime I press the button I keep receiving the invalid procedure call or argument error...

Any help? Am I forgetting to do something? I tried on Northwind and it worked....
 
You are missing the code between. Here is what Microsft had in the article that you referenced.
Code:
Private Sub clearListBox()
    Dim iCount As Integer
        
    For iCount = 0 To Me!NamesList.ListCount
        Me!NamesList.Selected(iCount) = False
    Next iCount
End Sub
 
You are missing the code between. Here is what Microsft had in the article that you referenced.
Code:
Private Sub clearListBox()
    Dim iCount As Integer
        
    For iCount = 0 To Me!NamesList.ListCount
        Me!NamesList.Selected(iCount) = False
    Next iCount
End Sub


I know! I was just giving an example. I keep getting the same error even with the code...
 
So this is your code and still you get an error?
Code:
Private Sub clrList_Click()
    clearListBox
End Sub

Private Sub clearListBox()
    Dim iCount As Integer

'Where [COLOR="Red"]NamesList [/COLOR]equals the name of your listbox!
        
    For iCount = 0 To Me![COLOR="red"]NamesList[/COLOR].ListCount
        Me![COLOR="red"]NamesList[/COLOR].Selected(iCount) = False
    Next iCount

End Sub
 
Compile the code. You should receive a compile error. Fix it.
 
I'm putting it under "Microdoft Office Access Class Objects" in Form_Form1
 
I've just solved it: I copied everything to a new database and it worked :)
 

Users who are viewing this thread

Back
Top Bottom