Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2009
    Posts
    32

    Unanswered: Module Format help

    Ok im trying to understand how to referance a listbox on one of my forms formt he module

    simple test:

    Public Function Tester()
    Dim Test (What should go here?)


    Set Test = Form.[New Call Form].lstLeads.ListCount() <--returns a number.


    MsgBox Test

    End Function

    I get that damn runtime error 424

    an ideas?

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    try something like
    Code:
    forms!myformname.mycontrolname.myproperty
    an alternative approach is after the code stops then using the immediate window examine the properties of any objects or variables as required.
    to do that prefix the line with a ? to examine the property / variable
    optherwise you can assign values
    to examine what is in a control called say MyListBox
    ?MyListBox.listcount
    to set a value
    MyVariable = 1234

    one thing to bear in mind is that when you restart code after breaking then there is a risk you may need to reinitialise some settings.
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Nov 2009
    Posts
    32
    Thanks healdem for taking the time to read my post and help out.

    I have tried:
    Dim Test As Control

    Set Test = Forms![New Call Form].lstLeads.ListCount()

    MsgBox Test

    End Function

    Same 424

    I also tired

    Dim Test As Control

    Set Test = Forms![New Call Form]!lstLeads.ListCount()

    MsgBox Test

    End Function

    Same error 424

    I even tried to :
    Dim Test As Control

    Set Test = Forms![New Call Form]?lstLeads.ListCount()

    MsgBox Test

    End Function

    But that gave me a compiler error

    All i want is the number of items in the list

    I guess my question is what is the proper way to access an object in a form from the module.

    I have the code :

    Dim Test As Integer

    Test = Me.lstLeads.ListCount()

    MsgBox Test

    End Sub

    as a sub in the form... and it works fine! Ive been looking at this code since this morining... and thought about it all night... my head hurts...

    Its like standing on the beach, and seeing a sea shell... and thinking... there has got to be an ocean around here.... and not seeing the ocean... right in front of me...

  4. #4
    Join Date
    Apr 2004
    Location
    Kingsland, Georgia
    Posts
    231
    i'm not understanding what you're looking for.
    If you're looking for the number of items in the list, just reference lstLeads.ListCount() like you've done. It returns a number, as you know. If you want to control the listbox, then dim Test As Listbox instead of as a control, and set Test=lstLeads. I just don't understand what you're asking for.

  5. #5
    Join Date
    Nov 2009
    Posts
    32
    The problem ended up being the [new call form] part. I renamed the form to frmnewcallform and used

    Set Test = Forms!frmnewcallform!lstLeads.ListCount()

    And it worked fine.

    Kinda dumb huh!
    lol

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •