BFanguy
asked on
Access 2010 Form OnPaint Event problems with me.xxx.value on continuous subform if has New Record (allowinserts)
I am trying to hide a button on a continuous subform if me.action = 5
If i open my subform as allow inserts = false it works fine.
if there is a >* record it fails stating that me.action can't find run-time error 2424
is there a way to test to see if I am on a >* record - testing for not IsNull on one of the fields evidently does not work.
any help is appreciated
Private Sub Detail_Paint()
me.mybutton.visible = False
If Not IsNull(Me.Action) Then ' this is somehow true on the new record >* ????
If Me.Action = 5 Then
me.mybutton.visible = False
End If
End If
End Sub
If i open my subform as allow inserts = false it works fine.
if there is a >* record it fails stating that me.action can't find run-time error 2424
is there a way to test to see if I am on a >* record - testing for not IsNull on one of the fields evidently does not work.
any help is appreciated
ASKER
If i do this on current it changes for all records on the continuous form.
i.e. if record 2 on my subform has a action of 5 all records on the subform show the button.
i only want the button to show when the action = 5 on the record.
i.e. if record 2 on my subform has a action of 5 all records on the subform show the button.
i only want the button to show when the action = 5 on the record.
ASKER
Let me clarify.
10 records display on the continuous subform.
button set to visible = false
2 have action = 5.
if i click on a record that has a action = 5 all 10 records show the button
if i click on a record that does not have a action = 5 none show the button.
10 records display on the continuous subform.
button set to visible = false
2 have action = 5.
if i click on a record that has a action = 5 all 10 records show the button
if i click on a record that does not have a action = 5 none show the button.
This may not be easy on a continuous form...
What I typically do is put the button in the form header (not the detail section)
...This way you only really have "one" button to deal with, ...then the current event and after Update evens should work fine.
Having a button on each line looks great until you need to do something like hiding the button for certain conditions. (which, as you see here, ...is not easy on a continuous form)
What you could do is just throw a message if they click the button:
If Me.Action = 5 Then
msgbox "Action is: " & me.Action & ". So you cant do this now"
End If
Or use conditional formatting in the detail section if the value of Me.Action is 5.
JeffCoachman
What I typically do is put the button in the form header (not the detail section)
...This way you only really have "one" button to deal with, ...then the current event and after Update evens should work fine.
Having a button on each line looks great until you need to do something like hiding the button for certain conditions. (which, as you see here, ...is not easy on a continuous form)
What you could do is just throw a message if they click the button:
If Me.Action = 5 Then
msgbox "Action is: " & me.Action & ". So you cant do this now"
End If
Or use conditional formatting in the detail section if the value of Me.Action is 5.
JeffCoachman
ASKER
When i open my continuous subform in design view and no matter where i click the Conditional formatting is grayed out. Tried the form, detail section, controls...
ASKER
ok. so evidently conditional formatting does not work on buttons..
it's a button i am trying to hide based on the value in a control.
is this possible?
thanks for all of your help.
it's a button i am trying to hide based on the value in a control.
is this possible?
thanks for all of your help.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you for your help!
Thanks
Glad I could help.
Glad I could help.
You will also have to add the same code to the After Update event of the "me.action" control...