passing value from 1 form to another form

  • Thread starter Thread starter K E Senthil Kumar
  • Start date Start date
K

K E Senthil Kumar

Hello,

I am using access forms to create an application using VBA. I use a main
form and 3 sub forms. In one form i use a field no_of_days. I want to use
the value in this filed to use a divide a sum on another subform. However,
the value is always coming as zero and divide by zero error occurs, even
though the value is 2.

the main form is called main, the first form form1 and 2nd form as form2. In
form2, i use the following code

nd = val(no_of_days)
total = val(filed1)+val(field) / nd

but this brings up always the divide by zero error. What am i doing wrong.

I tried to pass the value by naming it as

nd = val(forms!form1.for!no_of_days),

but this also is not working.

Any help would be appreciated

thanks

kesk
 
nd = val(forms!form1.for!no_of_days)

Try
nd = val(forms!main!forms!form1.no_of_days)

Krgrds,
Perry
 
K E Senthil Kumar said:
Hello,

I am using access forms to create an application using VBA. I use a main
form and 3 sub forms. In one form i use a field no_of_days. I want to use
the value in this filed to use a divide a sum on another subform. However,
the value is always coming as zero and divide by zero error occurs, even
though the value is 2.

the main form is called main, the first form form1 and 2nd form as form2. In
form2, i use the following code

nd = val(no_of_days)
total = val(filed1)+val(field) / nd

but this brings up always the divide by zero error. What am i doing wrong.

I tried to pass the value by naming it as

nd = val(forms!form1.for!no_of_days),

but this also is not working.

Any help would be appreciated

thanks

kesk

You can return the value in few way:
1)Public Variable Declaration
Insert a Module and put inside your Variable
In this way you Write the Variable Form any Form
and in the same way you read it from any Form...!
I don't like much this way, but work good

2)Each form can have personal Property.
If all properties are Public you can read and Write
into this Property From outside Form in this way:
Value=Form!Form1.PropertyName

Use for this metod inside Forms Public Property Let/Get declarations
On Help you can find some Sample.
This is my usually way.

You can have some more metod, but here you have the easiest.

Sorry for my bad ENGL.....!

Alessandro(IT)
 
Back
Top