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

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

Open in new window


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
BFanguyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jeffrey CoachmanMIS LiasonCommented:
Try it on the current even instead.

You will also have to add the same code to the After Update event of the "me.action" control...
0
BFanguyAuthor Commented:
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.
0
BFanguyAuthor Commented:
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.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Jeffrey CoachmanMIS LiasonCommented:
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
0
Jeffrey CoachmanMIS LiasonCommented:
like so, (on each control, set the the rule/condition to: Action=5, and set the background color to red)
cf
0
BFanguyAuthor Commented:
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...
0
Jeffrey CoachmanMIS LiasonCommented:
Conditional formatting only works with "controls" in a section, ...not on the section (backcolor) itself.
I apologize for not making that clear in my post.
cf 2

But the the screenshot I posted shows the conditional formatting in effect on the textbox controls when Action=5...
0
BFanguyAuthor Commented:
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.
0
Jeffrey CoachmanMIS LiasonCommented:
so evidently conditional formatting does not work on buttons
Correct.
(neither does it work on the section itself... Perhaps future versions will address this...

Again,...what is commonly done is to put the button in the form header.
Then the code:
If Me.Cation=5 Then
    Me.mybutton.Visible-False
else
     Me.mybutton.Visible-True
end if

Open in new window

...When put on both the current event of the form, and on the after update event of Me.Action, will result in the buttons visibility toggling according to the status of the Action field.

JeffCoachman
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BFanguyAuthor Commented:
Thank you for your help!
0
Jeffrey CoachmanMIS LiasonCommented:
Thanks
Glad I could help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.