Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

On Click Visible Is Not Saving

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Dear There,
I have a form with several box's, let say 1 to 10 with funny arrange, it's look like chess board, i put code behined each box on click,
Me.Box1.Visible = false
but when i close the form and reopen this box is showing.
How can i save the visible from code as design view, i mean i want each box i click it will be hide even when i reopen the form next time.

Thanx
Sorry For My English
 
each box has a tag item set the tag items for the visible boxes to 0 and set the tag items for the not visible boxes to 1

then on your code for each box do this

If Me.Tag = 0 Then
Me.Visible = False
Me.Tag = 1
Else
Me.Visible = False
Me.Tag = 0
End If

Then Do This For The On Current Event

OnCurrent_Event()
Dim intCtlCount As Integer

For intCtlCount = Me.Controls.Count
If Me.Controls(intCtlCount) = acTextBox Then
If Me.Tag = 0 Then
Me.Visible = False
Me.Tag = 1
Else
Me.Visible = False
Me.Tag = 0
End If
End If
Next inCtlCount

End Sub
 
Thanx ToeShot,

But may be you didn't understand my point, let me explain it well.
For example, i have form with 5 boxes, and i set all to visible = true, when i run my form the action i need to be, when i click on any box, the box should set to visible = false, then when i close the form and run it again, should that box still hide, i mean it's not saveing the properety of the visible...... more easy may be to understand

* New Form
* 5 Boxes, Visible = true
* run Form, Click on any box
* The box will be hide
* Close the form
* Run again
:((( the box is showing......

Please Help Me
Thanx
 
That is what my code insures. At design time when you set the property visible to true that is how it is retained. Meaning when ever you start your app that option will always be true no matter what the state of it was when you closed your app. But the tag property retains its ending value meaning if it ended with a 3 in it when you run your app again it retains that 3 that is how you use it to set your visible properties the next time the app is open. I hope this is more clear. I notice a mistake in part of my code so I am reposting it. Don't need to set the tag values in the OnCurrrent_Event()

OnCurrent_Event()
Dim intCtlCount As Integer

For intCtlCount = Me.Controls.Count
If Me.Controls(intCtlCount) = acTextBox Then
If Me.Tag = 0 Then
Me.Visible = True
Else
Me.Visible = False
End If
End If
Next inCtlCount

End Sub
 

How are you closing the form, you must set the option that saves the form to yes (acSaveYes) . e.g.


DoCmd.Close acForm, [Name], acSaveYes

 
When you choose to save the form it save change made in the design. So unless you are making changes at runtime, you don't need to save the form, it won't save the present state.
 
Thanx Every One,

I have solved.

In Moduel,

Public Bt1 As Boolean

In the Code

Private Sub But1_Click()
Bt1 = False
Me.But1.Visible = Bt1
End Sub

Private Sub Form_Load()
Me.But1.Visible = Bt1
End Sub

Good Luck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top