Results 1 to 12 of 12

Thread: [Resolved] Expected Funct or Var Issue

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2005
    Posts
    192

    Resolved [Resolved] Expected Funct or Var Issue

    Here is the code. Hopefully it is something simple. I'm still learning VB! I've been stuck on this one for quite a while! The combo box will not work correctly, however the list box does. I've tried dif combonations of the combo object and still no luck.

    Thanks for the help.

    VB Code:
    1. 'Populate UserList
    2.     '==============================
    3.     Dim rs As New ADODB.Recordset
    4.     Dim cn As New ADODB.Connection
    5.     Dim ITM As ListItem
    6.     Dim cb As ComboItem
    7.    
    8.    
    9.         cn.ConnectionString = frmMain.ConnectString
    10.         cn.Open
    11.             sql = "SELECT * FROM Users"
    12.         rs.Open sql, cn, adOpenForwardOnly, adLockOptimistic
    13.        
    14.             ListView1.View = lvwReport
    15.             ListView1.ColumnHeaders.Add 1, , "Autonumber"
    16.             ListView1.ColumnHeaders.Add 2, , "User"
    17.  
    18.         With rs
    19.             Do Until rs.EOF = True
    20.             Set ITM = ListView1.ListItems.Add(1, "", Trim(!autonumber))
    21.             Set cb = cmbAssigned.AddItem(rs.Fields("product"))
    22.             ITM.SubItems(1) = IIf(IsNull(!User), "", Trim(!User))
    23.             .MoveNext
    24.             Loop
    25.         End With
    26.        
    27.     'Populate Priority
    28.    
    29.     'Populate Status
    Last edited by DJHotIce; Jun 28th, 2005 at 05:59 PM.

  2. #2
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Expected Funct or Var Issue

    I think you are putting all the items in the first position, so that only the last shows. Take a look at this:

    VB Code:
    1. While Not mrsProducts.EOF
    2.                 Set itmX = lvFind.ListItems.Add(, , CStr(mrsProducts!ProductName))
    3.                 itmX.SubItems(1) = CStr(mrsProducts!SupplierID)
    4.                 itmX.SubItems(2) = mrsProducts!CategoryID
    5.                 mrsProducts.MoveNext
    6.             Wend

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jun 2005
    Posts
    192

    Re: Expected Funct or Var Issue

    Quote Originally Posted by dglienna
    I think you are putting all the items in the first position, so that only the last shows.
    Sorry to seem like a noobie. But could you boldize the item I need to look at. I'm looking hard yet see no resemblence. Maybe needs to be re-explained?

  4. #4
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: Expected Funct or Var Issue

    instead of this:

    Set ITM = ListView1.ListItems.Add(1, "", Trim(!autonumber))

    use this:

    Set ITM = ListView1.ListItems.Add(, "", Trim(!autonumber))

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jun 2005
    Posts
    192

    Re: Expected Funct or Var Issue

    Baja,

    That piece of code works perfectly

    This one that is giving me grief is this:
    VB Code:
    1. Set cb = cmbAssigned.AddItem(rs.Fields("product"))

  6. #6
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,123

    Re: Expected Funct or Var Issue

    VB Code:
    1. cmbAssigned.AddItem rs.Fields("product")
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Jun 2005
    Posts
    192

    Re: Expected Funct or Var Issue

    This gives me an end of statement error.
    VB Code:
    1. Set cb = cmbAssigned.AddItem rs.Fields(!User)

    This gives me a Expected Funct or Var Error
    VB Code:
    1. Set cb = cmbAssigned.AddItem(rs.Fields(!User))

    What am I doing wrong?

  8. #8
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,537

    Re: Expected Funct or Var Issue

    .AddItem isn't a function.... it's a method.... it should be exaclty as dee-u showed you:
    VB Code:
    1. cmbAssigned.AddItem rs.Fields("product")

    Tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Jun 2005
    Posts
    192

    Re: Expected Funct or Var Issue

    TG and others, tried this

    VB Code:
    1. Set cb = cmbAssigned.AddItem(rs.Fields("User"))
    Error above: Expected Function or Var. The .AddItem part is highlighted. I've also tried w/o the () surounding rs.Field...

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Jun 2005
    Posts
    192

    Resolved Re: Expected Funct or Var Issue

    Never Mind Remove the Set = part and it works perfectly now.

  11. #11
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,123

    Re: [Resolved] Expected Funct or Var Issue

    Did you ever read post #6 and 8?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Jun 2005
    Posts
    192

    Re: [Resolved] Expected Funct or Var Issue

    Quote Originally Posted by dee-u
    Did you ever read post #6 and 8?
    YES! I was being a stupid Noobie eh?

Posting Permissions

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



Click Here to Expand Forum to Full Width