cascading comboboxes and textbox

S

SteveP

I have a form with some comboboxes and text fields. The comboboxes I am
working with are called cboItem and cboDescription. The main text field I am
working with is called txtStandardCost. Right now, I have it as two
cascading comboboxes and a text field that I have to manually enter the
Standard Cost into. As much as I would love to make the cboDescription into
a text field, I want users to have the option of picking the description and
having the cboItem fill in with any correlating Item #s (company was
purchased by a larger company...still have 2 inventory management systems and
2 different numbering systems). My problem/question is how do I get the
txtStandardCost field to fill in automatically when the cboItem is filled in
while still having the cascading combobox effect still work? Field
names/order in the table is ID, Item, Description, StandardCost. Thank you
in advance for any and all help.
 
J

Jeanette Cunningham

Hi Steve,
something like this:
in after update for cboItem
me.txtStandardCost = me.cboItem.Column(1)

use whichever column in the cboItem has the standard cost in
me.txtStandardCost = me.cboItem.Column(1)

combo column numbering starts at 0, so the first column is Column(0)

Jeanette Cunningham
 
S

SteveP

I put in the line that you suggested in your reply, but the txtStandardCost
still does not populate. Here is the code I have in the afterupdate for
cboItem:

Private Sub cboItem_AfterUpdate()
Dim sDescription As String

sDescription = "SELECT
[Inventory06].[ID],[Inventory06].[Item],[Inventory06].[Description] " & _
" FROM Inventory06 " & _
" WHERE [Item]='" & Me.cboItem & "'"


Me.cboDescription.RowSource = sDescription
Me.cboDescription.Requery
Me.txtStandardCost = Me.cboItem.Column(3)
End Sub

Do I need to call out the column "StandardCost" in the sDescription line? I
did go back and double check the column names in the table, and field names
on the form to make sure they all match. StandardCost is the 4th column in
the table.

SteveP
 
J

Jeanette Cunningham

Try changing this line:
Me.txtStandardCost = Me.cboItem.Column(3)
to
Me.txtStandardCost = Me.cboItem.Column(2)

Jeanette Cunningham


SteveP said:
I put in the line that you suggested in your reply, but the txtStandardCost
still does not populate. Here is the code I have in the afterupdate for
cboItem:

Private Sub cboItem_AfterUpdate()
Dim sDescription As String

sDescription = "SELECT
[Inventory06].[ID],[Inventory06].[Item],[Inventory06].[Description] " & _
" FROM Inventory06 " & _
" WHERE [Item]='" & Me.cboItem & "'"


Me.cboDescription.RowSource = sDescription
Me.cboDescription.Requery
Me.txtStandardCost = Me.cboItem.Column(3)
End Sub

Do I need to call out the column "StandardCost" in the sDescription line?
I
did go back and double check the column names in the table, and field
names
on the form to make sure they all match. StandardCost is the 4th column
in
the table.

SteveP


Jeanette Cunningham said:
Hi Steve,
something like this:
in after update for cboItem
me.txtStandardCost = me.cboItem.Column(1)

use whichever column in the cboItem has the standard cost in
me.txtStandardCost = me.cboItem.Column(1)

combo column numbering starts at 0, so the first column is Column(0)

Jeanette Cunningham
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top