Frank Freese
asked on
reading values from one form into another
Experts,
I have two forms:
frmPreliminaryBonus
frmAdjustmentsToBonus
In frmPreliminaryBonus I have an option group called optSelectEmployee with four check boxes labeled:
ckDM (value = 1)
ckASM (value = 2)
ckSM (value = 3)
ckAsstSM (value = 4)
In frmAdjustmentToBonus I have an unbound text box called txtEmployee. Nothing assigned to the control source
Here's the code I use in the form load event of frmAdjustmensToBonus
trictManag er and assigned it to txt.Employee in my frmAdjustmentsToBonus
I have two forms:
frmPreliminaryBonus
frmAdjustmentsToBonus
In frmPreliminaryBonus I have an option group called optSelectEmployee with four check boxes labeled:
ckDM (value = 1)
ckASM (value = 2)
ckSM (value = 3)
ckAsstSM (value = 4)
In frmAdjustmentToBonus I have an unbound text box called txtEmployee. Nothing assigned to the control source
Here's the code I use in the form load event of frmAdjustmensToBonus
If Form!frmPremilinaryBonus.OptSelectEmployee.ckDM = 1 Then
Me.txtEmployee = Form!frmPreliminaryBonus.txtDistrictManager
End If
I keep gettin an error Monthly Bonus can't find the field 'frmPreliminaryBonus' referred to in your expression. I need to take the values in frmPreliminaryBonus.txtDis
If you check a Value from another Form, that particular Form needs to be open, else it will fail.
So is the Form 'frmPremilinaryBonus' open?
Then the code should be something like this:
If Form!frmPremilinaryBonus.O ptSelectEm ployee.Val ue = 1 Then
Me.txtEmployee = Form!frmPreliminaryBonus.t xtDistrict Manager
End If
Hope this helps,
Daniel
So is the Form 'frmPremilinaryBonus' open?
Then the code should be something like this:
If Form!frmPremilinaryBonus.O
Me.txtEmployee = Form!frmPreliminaryBonus.t
End If
Hope this helps,
Daniel
syntax is:
If this is truely an option group, then you don't need to refer to the checkbox, you refer to the optiongroup to get the value associated with the selected checkbox (of which you can only have one).
The syntax would be:
If Forms!frmPremilinaryBonus. OptSelectE mployee = somevalue
If this is truely an option group, then you don't need to refer to the checkbox, you refer to the optiongroup to get the value associated with the selected checkbox (of which you can only have one).
The syntax would be:
If Forms!frmPremilinaryBonus.
Good point of Capricorn, to make the beginning Forms, missed that! :)
If you check a Value from another Form, that particular Form needs to be open, else it will fail.
So is the Form 'frmPremilinaryBonus' open?
Then the code should be something like this:
If Forms!frmPremilinaryBonus. OptSelectE mployee.Va lue = 1 Then
Me.txtEmployee = Forms!frmPreliminaryBonus. txtDistric tManager
End If
If you check a Value from another Form, that particular Form needs to be open, else it will fail.
So is the Form 'frmPremilinaryBonus' open?
Then the code should be something like this:
If Forms!frmPremilinaryBonus.
Me.txtEmployee = Forms!frmPreliminaryBonus.
End If
is the error
< Monthly Bonus can't find the field 'frmPreliminaryBonus' referred to in your expression.>
gone when you use ?
If Forms!frmPremilinaryBonus.
Me.txtEmployee = Forms!frmPreliminaryBonus.
End If
I've never seen that syntax (trying to refer to a checkbox as though it were a child of an option group work).
When I try that, I get a runtime error #438 (Object doesn't support this property).
When I try that, I get a runtime error #438 (Object doesn't support this property).
if you are checking an Option Group, just use
If Forms!frmPremilinaryBonus. OptSelectE mployee = 1 Then
Me.txtEmployee = Forms!frmPreliminaryBonus. txtDistric tManager
End If
If Forms!frmPremilinaryBonus.
Me.txtEmployee = Forms!frmPreliminaryBonus.
End If
or do this
Select case Forms!frmPremilinaryBonus. OptSelectE mployee
case 1
Me.txtEmployee = Forms!frmPreliminaryBonus. txtDistric tManager
case 2
'code here
case 3
'code here
case 4
'code here
end select
Select case Forms!frmPremilinaryBonus.
case 1
Me.txtEmployee = Forms!frmPreliminaryBonus.
case 2
'code here
case 3
'code here
case 4
'code here
end select
ASKER
I'm in the form Load event:
After I correct a typo the code used is:
Object doesn't support this property or method/
When I use this code:
When I use this code:
After I correct a typo the code used is:
If Forms!frmPremilinaryBonus.OptSelectEmployee.ckDM = 1 Then
Me.txtEmployee = Forms!frmPreliminaryBonus.txtDistrictMgr
End If
and the error code isObject doesn't support this property or method/
When I use this code:
If Forms!frmPremilinaryBonus.OptSelectEmployee.Value = 1 Then
Me.txtEmployee = Forms!frmPreliminaryBonus.txtDistrictMgr
End If
I get no errors and no data.When I use this code:
If Forms!frmPreliminaryBonus.OptSelectEmployee = 1 then
Me.txtEmployee = Forms!frmPreliminaryBonus.txtDistrictMgr
End If
Here I get no error and no data.
That is probably because the value associated with ckDM is not 1. Open the form in design view, click on the checkbox and look at the data tab of the properties window. What is the option value associated with the checkbox.
However, if you have checkboxes, that are just laid on top of a option group, then you may actually be able to refer to them as:
Forms!frmPreliminaryBonus. ckDM, in which case the values would probably contain either 0 or -1.
However, if you have checkboxes, that are just laid on top of a option group, then you may actually be able to refer to them as:
Forms!frmPreliminaryBonus.
are you sure that the option group "OptSelectEmployee" was created properly ?
to be sure, create the Option group using the wizard .. it is very simple and easy.
to be sure, create the Option group using the wizard .. it is very simple and easy.
ASKER
I used the wizard but let me do it again just to make sure.
ASKER
I tried the Case Select which is much better than my plan - no errors - no data?
upload a copy of the db
ASKER
here you go - thanks. the db opens to the form with the option group.
StoreBonusRevX1.mdb
StoreBonusRevX1.mdb
where is the table " tblEmployeeStatus" ?
ASKER
didn't notice it was missing - hum? Anyway, I've imported it into this attachment. That's very strange...
StoreBonusRevX1.mdb
StoreBonusRevX1.mdb
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
was I kinda of close? that's exactly what I was asking for. Appreciate it very much.
ASKER
thank you cap:
this solution was accepted because the expert was able to repair the problems and offered up the best solution.
this solution was accepted because the expert was able to repair the problems and offered up the best solution.
If Forms!frmPremilinaryBonus.
Me.txtEmployee = Forms!frmPreliminaryBonus.
End If