Full Version: populating a subform
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
thereclinerman
sir, i have the following setup:

tblUnitofMeasure
PK UnitofMeasureID
UnitOfMeasure "text"

tblParts
PK PartID
fkCategoryID
PartName
fkUnitOfMeasureID (on the form i use for entry, this is a combo box)
PartPrice
Description

subForm Fields
cboCategory
cboParts
Quantity
u/m
price
description

in the subform, i put the following in cboCategory to populate the row source of cboPartID. It works good except the tblParts.fkUnitofMeasureID shows the foreign key from the bleParts instead of the UnitOfMeasure as text. how can i show the text of tblUnitOfMeasure in tblParts instead of the primary key. i can upload a sample db. thanks for any help.

Private Sub cboCategoryID_AfterUpdate()

cboPartID.RowSource = "SELECT tblParts.PartID,tblParts.PartName,tblParts.PartPrice,tblParts.Description,tblPar
ts.fkUnitOfMeasureID FROM" & _
" tblParts WHERE fkCategoryID = " & cboCategoryID & _
" ORDER BY PartName"

End Sub

Private Sub cboPartID_AfterUpdate()

Me.txtPrice = cboPartID.Column(2)
Me.txtDescription = cboPartID.Column(3)
Me.txtUnitOfMeasure = cboPartID.Column(4)

End Sub
Daryl S
Thereclinerman -

Is the combo box really on the fkUnitOfMeasureID, or is it really in the PK ParID? Usually a combo box used for selecting a value is bound to the field. If so, make sure the bound column is column 5, not column 1. This is in the Properties of the combo box.
thereclinerman
hi and thanks for the help. i included a data base so you could see what happens. you can look at the frmParts to see how i enter the parts and the frmBuildNewChair to see under u/m shows the primary key from tblParts. it is kind of like a query where you want to show the unit of measure (inch, foot, ea) instead of the key for each. thank youClick to view attachment
mike60smart
Hi

No Db attached?
thereclinerman
sorry, forget to add it. put in in the last post. when you build a new chair, for the cagegory select arm brackets then go down to the part name of test. thanks Click to view attachment
mike60smart
Hi

The zip file wont open - I would think you have zipped the file whilst it was still open

Try closing the DB first and then zipping it
thereclinerman
mike, it has been a while since i did this. sorry. here is a new one. i also emaied you.Click to view attachment
Daryl S
Thereclinerman -

If you are just asking to see the description of the unit of measure with (or without) the unit of measure ID, then on whatever form or query you use, just join to the Unit of Measure table and display that description. If you need more help, tell us where you want to see the U/M description (on a form or in a query), and we can help you display it.
thereclinerman
dayrl i am familiar with that. thanks. in the frmBuildChair, what i am trying to use as the row source of cboPart is being loaded by cboCategory in the afterupdate event. afterupdate event limits the parts from tblparts. i am using cboCategory afterupdate event to limit the choices in cboParts to just the category that was selected. tblparts has the fkUnitOfMeasure in it, and this fkKey is what is being selected and put in the U/M. I dont know how to link the fkUnitOfMeasure with the actual description in the visual basic which is in the afterupdate of cboCategory. on the frmBuildChair, subformBuildChair is where i need to see the description. thanks for taking the time. jim
Daryl S
If you want to see the description of the U/M in the subform, then you should alter your recordsource for the subform to include it. If your recordsource for the subform is just the tblparts for example, then change the recordsource to be this:

SELECT tblparts.*, tblUnitOfMeasure.Description
from tblparts LEFT JOIN tblUnitOfMeasure on tblparts.fkUnitOfMeasure = tblUnitOfMeasure.UnitOfMeasureID;

Then you will have Description available in the subform to display the text value of the Unit of Measure.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.