Funny Problem

Solo712

Registered User.
Local time
Today, 09:13
Joined
Oct 19, 2012
Messages
838
This is sort of a brain-teaser (if that is allowed here). I already have a work-around but thought it interesting to share it with the board to see if perhaps better solution might exist.

I have created a fancy-schmancy form for a payroll program which can be used to enter time sheet data into the current pay period or read time sheet data from all periods. I created all the necessary handling of the switching between the size of the filter and allowing/disallowing edits on the form. Then I created a checkbox to that purpose. Alas, the switch could be only flipped once. Then it would not respond. As I was particularly thick that night, I could not figure out why. When the fog lifted I realized that the button was a form control and so itself was subject to the "Allow Edits" setting, so when the property was turned off, the check box (or radio button) would not flip. Great !

So all that work for nothing ! Luckily, I found a solution which allowed to keep all the references to "CheckEdits" switch intact with only a minor cosmetic change. How would you fix it ?

Best,
Jiri
 
Ok then, no takers.

So you can't use a radio button or a checkbox - to turn the form's "AllowEdits" off an and on. But you can use a small coloured square (or a button with a changing caption) to switch the value previously assigned to the radio button/checkbox to flip the value of a Boolean variable named the same way as the old switch control (which has to be visible to the whole form). Then rename the "OnClick" event to the new control....and the problem is solved. Here are two pictures to illustrate the sides of the "switch" of the edits.

Thanks for your undivided attention ! :)
 

Attachments

  • switch_demo.jpg
    switch_demo.jpg
    94 KB · Views: 105
  • switch_demo2.jpg
    switch_demo2.jpg
    92.3 KB · Views: 111
You could use the control's OnEnter/OnExit events.
Something like below:
Code:
Private Sub YourCheckBoxName_Enter()
  Me.AllowEdits = True
End Sub
Code:
Private Sub YourCheckBoxName_Exit(Cancel As Integer)
  If Not Me.YourCheckBoxName Then
    Me.AllowEdits = False
  End If
End Sub
 
You could use the control's OnEnter/OnExit events.
Something like below:
Code:
Private Sub YourCheckBoxName_Enter()
  Me.AllowEdits = True
End Sub
Code:
Private Sub YourCheckBoxName_Exit(Cancel As Integer)
  If Not Me.YourCheckBoxName Then
    Me.AllowEdits = False
  End If
End Sub

I guess that would work too assuming the On_Enter event fires with the "AllowEdits" off. You checked it ?

Best,
Jiri
 
I guess that would work too assuming the On_Enter event fires with the "AllowEdits" off. You checked it ?

Best,
Jiri
What exactly do you mean?
I always test my code, else I write in the replay "Not tested"! :)
But did you try the code, (any error message)?
 

Users who are viewing this thread

Back
Top Bottom