|
-
Jun 27th, 2005, 08:59 PM
#1
Thread Starter
Addicted Member
[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:
'Populate UserList
'==============================
Dim rs As New ADODB.Recordset
Dim cn As New ADODB.Connection
Dim ITM As ListItem
Dim cb As ComboItem
cn.ConnectionString = frmMain.ConnectString
cn.Open
sql = "SELECT * FROM Users"
rs.Open sql, cn, adOpenForwardOnly, adLockOptimistic
ListView1.View = lvwReport
ListView1.ColumnHeaders.Add 1, , "Autonumber"
ListView1.ColumnHeaders.Add 2, , "User"
With rs
Do Until rs.EOF = True
Set ITM = ListView1.ListItems.Add(1, "", Trim(!autonumber))
Set cb = cmbAssigned.AddItem(rs.Fields("product"))
ITM.SubItems(1) = IIf(IsNull(!User), "", Trim(!User))
.MoveNext
Loop
End With
'Populate Priority
'Populate Status
Last edited by DJHotIce; Jun 28th, 2005 at 05:59 PM.
-
Jun 27th, 2005, 09:26 PM
#2
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:
While Not mrsProducts.EOF
Set itmX = lvFind.ListItems.Add(, , CStr(mrsProducts!ProductName))
itmX.SubItems(1) = CStr(mrsProducts!SupplierID)
itmX.SubItems(2) = mrsProducts!CategoryID
mrsProducts.MoveNext
Wend
-
Jun 27th, 2005, 09:28 PM
#3
Thread Starter
Addicted Member
Re: Expected Funct or Var Issue
 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?
-
Jun 27th, 2005, 09:48 PM
#4
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))
-
Jun 27th, 2005, 09:54 PM
#5
Thread Starter
Addicted Member
Re: Expected Funct or Var Issue
Baja,
That piece of code works perfectly 
This one that is giving me grief is this:
VB Code:
Set cb = cmbAssigned.AddItem(rs.Fields("product"))
-
Jun 28th, 2005, 02:35 AM
#6
Re: Expected Funct or Var Issue
VB Code:
cmbAssigned.AddItem rs.Fields("product")
-
Jun 28th, 2005, 08:47 AM
#7
Thread Starter
Addicted Member
Re: Expected Funct or Var Issue
This gives me an end of statement error.
VB Code:
Set cb = cmbAssigned.AddItem rs.Fields(!User)
This gives me a Expected Funct or Var Error
VB Code:
Set cb = cmbAssigned.AddItem(rs.Fields(!User))
What am I doing wrong?
-
Jun 28th, 2005, 08:48 AM
#8
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:
cmbAssigned.AddItem rs.Fields("product")
Tg
-
Jun 28th, 2005, 05:53 PM
#9
Thread Starter
Addicted Member
Re: Expected Funct or Var Issue
TG and others, tried this
VB Code:
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...
-
Jun 28th, 2005, 05:59 PM
#10
Thread Starter
Addicted Member
Re: Expected Funct or Var Issue
Never Mind Remove the Set = part and it works perfectly now.
-
Jun 28th, 2005, 07:29 PM
#11
Re: [Resolved] Expected Funct or Var Issue
Did you ever read post #6 and 8?
-
Jun 28th, 2005, 09:26 PM
#12
Thread Starter
Addicted Member
Re: [Resolved] Expected Funct or Var Issue
 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|