Help with AddItem method ... missing from menu?

  • Thread starter Thread starter Thomas
  • Start date Start date
T

Thomas

I am using MS Access 2000 (9.0.6926 SP-3) with MS OS Windows 2000 at work.
The AddItem method is missing? At home I have MS XP OS and running Access
2000 and AddItem method is available and runs fine. I transport it to work
and get a run time error. Is there a missing .dll or library with MS
Windows 2000?

Thank you for your kind cooperation.

Thomas Vincent
 
What object has that method? Listboxes? I know in VB the
listboxes have an AddItem method, but Access listboxes do
not. If you give a bit more information, like what code
you are running, we can help out more.


Chris
 
Hi Chris,

This is the code I am trying to run.

The first error, it hits the .RemoveItem throwing "Method or Data member not
found.

The second one, it hits the .AddItem and throws the same error.

Finally it throws error on rs.open line

error lines are highlighted in RED

This is the code;

Private Sub cboPartNo_BeforeUpdate(Cancel As Integer)

Dim rs As adodb.Recordset

Dim sqlstr As String

Dim quote As String

Dim nCount As Long


quote = """"


Set cnn = CurrentProject.Connection

Set rs = New adodb.Recordset

'cboPartNo, cboProdGrp, cboTherapy, cboProjMgr are comboboxes

sqlstr = "select OraclePartInventory.[Item Description]," + _

"OProdGroup.Description, OProdGroup.ProjMgr_ID," + _

"OProdGroup.TherapyLine_ID FROM OProdGroup, OraclePartInventory"

sqlstr = sqlstr + " where OProdGroup.ProdGroupID_TX =
OraclePartInventory.ProdGroupID_TX"

sqlstr = sqlstr + " and OraclePartInventory.[item Number]="

sqlstr = sqlstr + quote + cboPartNo.Value + quote


rs.Open sqlstr, cnn, adOpenKeyset, adLockPessimistic, adCmdText


' MsgBox rs.RecordCount

nCount = 0

If cboProdGrp.ListCount > 0 Then

Do While cboProdGrp.ListCount > 0

cboProdGrp.RemoveItem (nCount)

nCount = nCount + 1

Loop

End If

nCount = 0

If cboTherapy.ListCount > 0 Then

Do While cboTherapy.ListCount > 0

cboTherapy.RemoveItem (nCount)

nCount = nCount + 1

Loop

End If

nCount = 0

If cboProjMgr.ListCount > 0 Then

Do While cboProjMgr.ListCount > 0

cboProjMgr.RemoveItem (nCount)

nCount = nCount + 1

Loop

End If


If rs.RecordCount > 0 Then

PartDesc.Value = rs.Fields(0).Value

cboProdGrp.AddItem rs.Fields(1).Value, 0

cboTherapy.AddItem rs.Fields(3).Value, 0

cboProjMgr.AddItem rs.Fields(2).Value, 0

End If


rs.Close

End Sub

Thank you and have a Good day!

Rajesh Candamourty
 
Okay, this is what I gather you are doing:

You have a combo box (cboPartNo) that you then want to
update 3 other fields (cboProdGrp, cboTherapy, cboProjMgr).

Here is my question: It seems to me that there will only
be 1 record per Part Number you select. If that is the
case, I would use 3 text boxes instead of cboProdGrop,
cboTherapy, cboProjMgr.

I would also use this as the Recordsource as the cboPartNo
combobox:

select OraclePartInventory.[item
Number],OraclePartInventory.[Item
Description],OProdGroup.Description, OProdGroup.ProjMgr_ID,
OProdGroup.TherapyLine_ID FROM OProdGroup,
OraclePartInventory
where OProdGroup.ProdGroupID_TX
=OraclePartInventory.ProdGroupID_TX


Now, for the cboPartNo column widths, use 1;0;0;0;

Three of the columns are hidden, but you can still
reference them.

For the textboxes, use =cboPartNo.Columns(1)
through .Columns(3).


This should work for what you are trying to do. If the
query pulls multiple partNo's, we'll have to do things
slightly differently.



Chris



-----Original Message-----
Hi Chris,

This is the code I am trying to run.

The first error, it hits the .RemoveItem throwing "Method or Data member not
found.

The second one, it hits the .AddItem and throws the same error.

Finally it throws error on rs.open line

error lines are highlighted in RED

This is the code;

Private Sub cboPartNo_BeforeUpdate(Cancel As Integer)

Dim rs As adodb.Recordset

Dim sqlstr As String

Dim quote As String

Dim nCount As Long


quote = """"


Set cnn = CurrentProject.Connection

Set rs = New adodb.Recordset

'cboPartNo, cboProdGrp, cboTherapy, cboProjMgr are comboboxes

sqlstr = "select OraclePartInventory.[Item Description]," + _

"OProdGroup.Description, OProdGroup.ProjMgr_ID," + _

"OProdGroup.TherapyLine_ID FROM OProdGroup, OraclePartInventory"

sqlstr = sqlstr + " where OProdGroup.ProdGroupID_TX =
OraclePartInventory.ProdGroupID_TX"

sqlstr = sqlstr + " and OraclePartInventory.[item Number] ="

sqlstr = sqlstr + quote + cboPartNo.Value + quote


rs.Open sqlstr, cnn, adOpenKeyset, adLockPessimistic, adCmdText


' MsgBox rs.RecordCount

nCount = 0

If cboProdGrp.ListCount > 0 Then

Do While cboProdGrp.ListCount > 0

cboProdGrp.RemoveItem (nCount)

nCount = nCount + 1

Loop

End If

nCount = 0

If cboTherapy.ListCount > 0 Then

Do While cboTherapy.ListCount > 0

cboTherapy.RemoveItem (nCount)

nCount = nCount + 1

Loop

End If

nCount = 0

If cboProjMgr.ListCount > 0 Then

Do While cboProjMgr.ListCount > 0

cboProjMgr.RemoveItem (nCount)

nCount = nCount + 1

Loop

End If


If rs.RecordCount > 0 Then

PartDesc.Value = rs.Fields(0).Value

cboProdGrp.AddItem rs.Fields(1).Value, 0

cboTherapy.AddItem rs.Fields(3).Value, 0

cboProjMgr.AddItem rs.Fields(2).Value, 0

End If


rs.Close

End Sub

Thank you and have a Good day!

Rajesh Candamourty



Thomas said:
I am using MS Access 2000 (9.0.6926 SP-3) with MS OS Windows 2000 at work.
The AddItem method is missing? At home I have MS XP OS and running Access
2000 and AddItem method is available and runs fine. I
transport it to
work
and get a run time error. Is there a missing .dll or library with MS
Windows 2000?

Thank you for your kind cooperation.

Thomas Vincent


.
 
Hi Chris

Thank you for all your help. We used your recommendation, the listBox
instead of the ComboBox and it worked just fine. Thank you again for all
your help. Have a very nice day.

Thomas
 
Back
Top