Form Query!

Carly

Registered User.
Local time
Today, 18:48
Joined
Apr 16, 2003
Messages
86
What I would like to do is the following:

I have a number of buttons on a form set out in an order in which the user has to press them.

Once the user has gone onto Stage 2 I would like Stage 1 to disappear. I can do this by attaching a macro
(i.e. [Forms]![FormName]![controlName].visible,False)
to the OnGetFocus function of the Stage 2 button.

The problem I've got is that the End User could be doing this over a couple of days, and every time I close the form & re-open it, it resets all the buttons back to visible.

Is there anyway that I can get the form to stop refreshing when it opens?

Regards
Carly
 
2 options

1) edit the design of the form, making the change permanent

2) save the progress of the user, then when the form is loaded use the saved info to hide the appropriate buttons.


ShadeZ
 
I don't want the change to be permanent as when they get to stage 7 for example I want all the fields to be visible again for them to start the whole process again.
 
Have you considered using the On Current event of the form? You can set it based on the criteria of the information...

Example:

Select Case Me.Stage
Case is = 1
Me.Commandbutton1.visible = False
Case is = 2
Me.Commandbutton1.visible = False
Me.Commandbutton2.visible = False
Case is = 3
Me.Commandbutton1.visible = False
Me.Commandbutton2.visible = False
Me.Commandbutton3.visible = False

End Select

HTH
 
I assume with this example that the user would have to be closing the form the same amount of times, but I will never know how many times they would want to.

They may finish Stage 1 to Stage 7 in one day - 1 week, but the next week they may need 2 days to do the same job.

This is why I need it just to remember the format of the form when it was shut down, as it could be a different stage each time
 
What you need to do is store the status of the user, in this case we use the registry.

use the code below to store info. Best place to put it is on button_click.

Code:
SaveSetting CurrentProject.Name, "FormSetup", button1.Name,button1.visible
'Note you need to repeat this for all the buttons

then on form load

Code:
sub form_load()
      button1.visible= getsetting(currentproject.name,"FormSetup",button1.name,"0")

      button2.visible= getsetting(currentproject.name,"FormSetup",button2.name,"0")

      button3.visible= getsetting(currentproject.name,"FormSetup",button3.name,"0")

      button4.visible= getsetting(currentproject.name,"FormSetup",button4.name,"0")
end sub

NOTE the above exaple is user specific.




i hope you can make sence of this


ShadeZ
 
When I add these codes the button1 is always invisible when I open the form, I never get a chance to click the button first.

Do I copy exactly what you have typed other than changing button1 for my button name?
 
you will need to change the Button name to your button name.

oh and i made a mistake the example i gave you would hide the buttons as defualt use

Code:
button2.visible= getsetting(currentproject.name,"FormSetup",button2.name,"1")

instead, this will set the buttons visible by default. ( its the differece of the 0 or 1 at the end)
 
I think this now works but just to be awkward, it there anything I can put into the code to put the form back to normal straight away, for testing purposes as now when I go back in to test it the button is always invisible.

i.e. Like a option, click OK to put it back to it's original state (all buttons visible) or Cancel to carry on (some buttons invisible)
 
all you have to do, is reset the form making all the buttons visible.

add a new button (BtnReset) to your form and place then code in the click event.

Code:
sub BtnReset_click()
        button1.visible = true
        button2.visible = true
        button3.visible = true
        button4.visible = true
        SaveSetting CurrentProject.Name, "FormSetup", button1.Name,button1.visible
        SaveSetting CurrentProject.Name, "FormSetup", button2.Name,button2.visible
        SaveSetting CurrentProject.Name, "FormSetup", button3.Name,button3.visible
        SaveSetting CurrentProject.Name, "FormSetup", button4.Name,button4.visible

when you are finished testing just remove your reset button.


Another way to reset the registry is to use "regedit".
 

Users who are viewing this thread

Back
Top Bottom