Subform Code Question

fenhow

Registered User.
Local time
Yesterday, 17:16
Joined
Jul 21, 2004
Messages
599
Hi,

I have this subform I am trying to run this code on, I have tried placing the code on the subforms Onload event and other areas but it will not work properly. Can someone tell me where to put this code please?

If Me!TotalGranteeAcres < Me!FixedLessThanValue Then

Me!MinimumAcreagePayout.Visible = True
Me!DividedInterestPayout.Visible = False
Me!NormalCalculationPayout.Visible = False
Me!NormalCalculation.Visible = False
Else
Me!MinimumAcreagePayout.Visible = False
Me!DividedInterestPayout.Visible = False
Me!NormalCalculationPayout.Visible = True
Me!NormalCalculation.Visible = True

End If

If Me!UI = 1 Then
Me!MinimumAcreagePayout.Visible = False
Me!DividedInterestPayout.Visible = True
Me!NormalCalculationPayout.Visible = False
Me!NormalCalculation.Visible = False

End If
EndSub


Thanks.

Fen How
 
Get rid of the BANGs (!) and use the dot to let Access know you want the CONTROLS (if the controls are named the same as the fields - which is the Access default if it added them to the form).
 
Thanks Bob, I did that but when I load the main form, the code does not run or refresh in the sbuform, where to I place the code? Here is the revised.

Private Sub Form_Load()
If Me.TotalGranteeAcres < 1.25 Then

Me.MinimumAcreagePayout.Visible = True
Me.DividedInterestPayout.Visible = False
Me.NormalCalculationPayout.Visible = False
Me.NormalCalculation.Visible = False
Else
Me.MinimumAcreagePayout.Visible = False
Me.DividedInterestPayout.Visible = False
Me.NormalCalculationPayout.Visible = True
Me.NormalCalculation.Visible = True

End If
End Sub
 
Thanks Bob, I did that but when I load the main form, the code does not run or refresh in the sbuform,
Why would they refresh when the main form loads? The subform loads first and that has the info as shown. If you are trying to refer to any fields on the main form then the syntax is different. Can you elaborate as to what you expect when the main form loads?
 
Thanks, all the fields are in the subform, not calling anything in the main form. The Subform shows data as it is related to the record selected in the main form but thats it.

The subform is driven from a query. In the subform for an example, if I am in a record that the TotalGranteeAcres is greater than 1.25 I want the txtbox MinimunAcreagePayout to be visible, and if I go to another record in the main form say the TotalGranteeAcres is less than 1.25 I want MinimumAcreagePayout to be hidden but when I move between records the textboxes on my subform are not hiding and / or showing like the code calls??

I am stumped.

Fen

I have similar code on a report under the "OnFormat" event and it works great.

Fen
 
Thanks, I placed it there and for some reason it will not go. Not sure why because it seems pretty straight foward. Can I call a control by its field name? versus its control source? for and example the field TotalGranteeAcres is a calculated field on the form.

Fen
 
Thanks, I placed it there and for some reason it will not go. Not sure why because it seems pretty straight foward. Can I call a control by its field name? versus its control source? for and example the field TotalGranteeAcres is a calculated field on the form.

Fen

On a form, you need to refer to the control name, however in this case, since it is a calculated field, that could have to do with why it isn't working. Perhaps the timing just isn't right for it to gather that info when it needs it.
 
Bob,

For simplicity sake I tried this.

On the subform I have a txtbox bound to the query called OWNERINT it has either a 1 or a 2 value.

I have another txtbox called DividedInterestPayout so what I want is, if OWNERINT is 1 show the txtbox if not hide it.

No luck, anything obvious?

Private Sub Form_Current()
If Me.OWNERINT = 1 Then

Me.DividedInterestPayout.Visible = True
Else
Me.DividedInterestPayout.Visible = False


End If

End Sub
 
Can you post a copy of your db with just a few records to see the problem? I might be able to spot it right away.
 
Sure, rather send private versus post public are you okay with that?

Fen
 
Sure, rather send private versus post public are you okay with that?

Fen
You'll have to wait for about 6 hours or so for me to get home (I can't get my private email while at work), otherwise I could do it immediately if uploaded here. Your choice.
 
Here you go. Split DB. Area in question. Surface Tab, Payout Details Tab, Subform Header.

Thanks.

Fen
 
Here you go. Split DB. Area in question. Surface Tab, Payout Details Tab, Subform Header.

Thanks.

Fen
It didn't attach. Make sure to compact and repair both FE and BE and I would zip and attach them separately.
 
Bob, if you are still willing to help I will be happy to email you the DB.

Thanks

Fen
 

Users who are viewing this thread

Back
Top Bottom