G
Guest
in my form how can i have a field look up a rate in table 1 and have it put
it in table 2 record for wich my form is for.
it in table 2 record for wich my form is for.
in my form how can i have a field look up a rate in table 1 and have it put
it in table 2 record for wich my form is for.
John,
I have 2 tables one stores the cost of ingredients eg. cement cost = .123
these cost may or may not go up throught the year. then on a daily
production report i have a formula using cement as one of the ingredients and
would like my form to automatically fill in a text box with the latest cement
cost and have that value stored in daily production table for that particular
record on that day. I have tried to use dlookup but only return #name? error.
help anyone, please
OK, I have a tabel for ingredients ( several ingredients ) three fields
date name and cost
I have another table daily production where I am using a form to pull data
in from different tables along with input of daily information. then there
will be a report that does a daily produciton cost . This report will use the
cost of each ingredient for each specific day. the ingredient cost may go
up every month or may stay the same but for calculating purpose I thought
storing the ingredient cost on the daily production report would insure the
cost would be calculated at the correct rate each time. But that would be
storing the cost in two different tables. should i just leave that cost data
in the ingredient table. When I calculat a year to date average of daily
cost how will it effect my data.
John,
I did try your suguestion the combo box worked ok, I used the wizard to set
it up and bound it to material 1 then bound a tex box to ingredient cost 1
used your vb code in the afterupdate and the text box would show the cost
for the the first ingredient in the table, but when the combo box is changed
the cost stayed the same it does not change.
Combo box
name material 1
Controll source ingredient 1
Row source SELECT ingredients.ID, ingredients.[material name],
ingredients.unitcost FROM ingredients;
ingredient table name is ingredients
date
material name
unit cost
source
Daily Production Table name is Daily Block
ingredient 1
cost 1
ingredient 2
cost 2
ingredient 3
cost 3
there may be 5 up to 7 ingredients used on any given day and ingredient may
change from day to day depending on what type of block are made.
thanks john
ps I tried fooling around with the after upday code and now i am getting
errors is there a way to clear the vba codes i put in.
John Vinson said:Answers inline.
Combo box
name material 1
Controll source ingredient 1
Row source SELECT ingredients.ID, ingredients.[material name],
ingredients.unitcost FROM ingredients;
You might want to add ORDER BY [Material name] to the SQL so the
materials are sorted alphabetically.
ingredient table name is ingredients
date
material name
unit cost
source
Daily Production Table name is Daily Block
ingredient 1
cost 1
ingredient 2
cost 2
ingredient 3
cost 3
there may be 5 up to 7 ingredients used on any given day and ingredient may
change from day to day depending on what type of block are made.
This table is INCORRECTLY STRUCTURED. You're making the very common
error of "committing spreadsheet". In a relational database, tables
should grow DOWN, not across. You should have *TWO* tables in a one to
many relationship; the "one" table would have information about the
"daily block" - but *nothing* about ingredients; the other table would
have a link to the Daily Block table, an IngredientID, and a Cost
field. If a batch has five ingredients the table will have five rows
for that batch; if it has eight, eight rows (which would be impossible
to handle in your current design!). It then becomes much, much easier
to sum up the cost for a batch.
thanks john
ps I tried fooling around with the after upday code and now i am getting
errors is there a way to clear the vba codes i put in.
Open the VBA editor, select the code using the mouse or by holding
dowh Shift and using the up/down arrow keys, and press the Delete key.
It's just a text editor - you can edit the VBA code just as you would
edit text in Notepad or Word.
You didn't post your code so I cannot help with your question as to
why the code is not working.
John W. Vinson[MVP]
So, you say I should design a form that will put data into each different
table.
I have many tables for this project
employess for hours
ingedients for cost
block for blocky type
customers for customer name
would one form be able to put data into each table and when i need the
produciton report i would then use a common field like the date to compile a
report.
Ok back to problem at hand,
Private Sub cboingredient1_AfterUpdate()
Me!txtcost1 = cboingredient1.Column(2)
End Sub
this is the code for my after update it does not work as written
this is the combo box row source
SELECT ingredients.ID, ingredients.[material name], ingredients.unitcost
FROM ingredients;
and the combo box name is ingredient1
and the text box name is cost1
thanks again for your help. bart