Question The problem....The solution??

tselie115

Registered User.
Local time
Today, 14:42
Joined
Aug 10, 2008
Messages
44
i am using this function to calculate dim1 on the afterupdate event of a combobox which is material.
the list of the material combobox and the formula are in one linked table.
the problem is that the dim1 is updated with only the first entry of the formula values in the table no matter wat i choose from the combobox list.
i just need the dim1 to be updated with the correspondant formula to the material chosen in the combobox.(formula corresponding to the same row of the material):eek:

Private Sub Material_AfterUpdate()
dim1 = getExposure(Form_Products.size1p.Value, Form_Products.size2p.Value, Form_subtypes.Formula)
End Sub


Public Function getExposure(x, y, z) As Variant
Do While InStr(z, "Valx") > 0
z = Left(z, InStr(z, "Valx") - 1) & Trim(Str(x)) & Mid(z, InStr(z, "Valx") + 4)
Loop
Do While InStr(z, "Valy") > 0
z = Left(z, InStr(z, "Valy") - 1) & Trim(Str(y)) & Mid(z, InStr(z, "Valy") + 4)
Loop
getExposure = Eval(z)
End Function



 
Since you do not appear to be changing the values of Form_Products.size1p.Value, Form_Products.size2p.Value or Form_subtypes.Formula why do you expect to get different results from changing the value in Material :confused:
 
the values are changing indeed.
in fact this material combobox is a subform of a form1 dat contains size1p and size2p.
these are changing for each record of form1.
and the formula is also changing.
in fact this function treats the formula entered by the user in the field formula and calculate dim1 accrodingly.
so formula is a field in a table that have different values.
example.

Size1p=1 Size2p=2
material formula
-------- -------
frame 2*size1p+3*size2p
arch (size1p+Size2p)

the problem is no wat mater wat ichose from material it is always executing the first formula(2*size1p+3*size2p) with the appropriate sizes.
 
In the code you have published you always are using getExposure for your calculation. You never seem to be using the parameter Formula. perhaps if you posted a sample of your DB we could investigate this for you.
 
the function is based on module of this database.
check the table to see how the formula is changing and the parameters that are Valx and Valy now to be Size1p and Size2p
 

Attachments

i added to this table a text field named material.
and im seeding a combobox in another form with the materials from this table.
i want the dim1 to be calculated based on the corresponding formula to the material chosen in the combobox
 
Private Sub Material_AfterUpdate()
dim1 = getExposure(Form_Products.size1p.Value, Form_Products.size2p.Value, Form_subtypes.Formula)
End Sub

i found out that the problem is with the last parameter of the function(in red)
when the form subtypes in not loadedm the formula used is always the first one.
if i load the form, i point to the second row(second formula), the fuction will execute using the second formula.
so how to refer in the function to the formula corresponding to the material chosen in the combo box?

 

Users who are viewing this thread

Back
Top Bottom