hey
Really strugling with Access today so i could do with some help :)

I'm attempting to add items to a list box. The Sources are 2 text boxes which have been fed to from a querey. So first I tried...

lstReorder.AddItem (ITEM_NUMBER.Text)
lstReorder.AddItem (ITEM_DESCRIPTION_1.Text)

Which brought up the error message
Run Time error '2185' - You cant referance a property or method for a control unless the control has the focus.

So i made sure that the querey was set up right by deselecting the backwards E, and i still get the same error.

I then changed the code to

lstReorder.AddItem (ITEM_NUMBER.Value)
lstReorder.AddItem (ITEM_DESCRIPTION_1.Value)

and i get the error message '6014' - The RowSourceType must be set to 'value list' to use this method

Ive tried every way i know how... and still no luck
Any help would be appreciated
Thanks, Michael

I think it's because of the parenthesis, Im' not sure I have no VB here but try to ommit that parenthesis.

With lstReorder    
               .AddItem  ITEM_NUMBER.Text    
               .AddItem ITEM_DESCRIPTION_1.Text
         End With

HI,
No problem with the paranthesis,

no issues if u palcwe or not placing the paranthesis next to the additem property.

With regards
Venkatramasamy SN

Well i actually have 4 text boxes that will be fed to the list box. Its for a Stock Reorder System. The user analyses some of the data, and then decides how many they want to order of that particular item, and then if they wish to change the previous selling price. So i will be adding many records to the list box and then printing the contents of the list box as a reorder list.

The With Statement still does not work :(

With lstReorder
.AddItem ITEM_NUMBER.Text
.AddItem ITEM_DESCRIPTION_1.Text
End With

Gives me The same error message

Run Time error '2185' - You cant referance a property or method for a control unless the control has the focus.

How do i make the Text box the focus??

Any ideas from anyone?
Thanks :)

share the answer please, so if someone get a same problem he can solved it.
thanks friend :)

Well i'm still not sure what i did! but here's the working code.

Option Explicit

Dim ItemNumber As String
Dim ItemDescription As String
Dim Qtytoorder As String
Dim AmmendPrice As Currency

Private Sub cmdAdd_Click()

ItemNumber = ITEM_NUMBER.Value
ItemDescription = ITEM_DESCRIPTION_1.Value

AmmendPrice = txtAmmendPrice.Value
Qtytoorder = txtqtytoorder.Value

With lstReorder
.AddItem AmmendPrice
.AddItem Qtytoorder
.AddItem ItemNumber
.AddItem ItemDescription
End With

End Sub

I have no idea what made this different from the other suggested code... but it WORKS :)

Its still not finished... i need to change it so that the Text boxes are all added to the List box as one record... so i'm looking into that now!! something to do with arrays if i remember back to my college years...

Thanks for the help guys and gals

This question has already been answered. Start a new discussion instead.