PC Review


Reply
Thread Tools Rate Thread

Change form property at runtime

 
 
Rick Brandt
Guest
Posts: n/a
 
      31st May 2010
johnb wrote:

> Hi Guys,
>
> I can change a controls visible property at runtime using a cmd button,
> but I can't seem to save the new setting when I close the Form and reopen
> it. The following code works fine apart from persisting the changes
> For Each ctl In frm.Controls
>
> If ctl.ControlType = acLabel And ctl.Name = Me.GroundInFocus.Value
> Then
> str = "I-" & Mid(ctl.Name, 1, 11)
>
> If Me(str).Visible = True Then
> Me(str).Visible = False
> Me(str).Properties("Visible").Value = False
> Else
> Me(str).Visible = True
> Me(str).Properties("Visible").Value = True
> End If
>
> End If
>
> Next ctl
> Set ctl = Nothing
>
> Any suggestion?


Changes made to a form or report in normal view via code are not supposed to
be persisted. For that you open the form in design view.
 
Reply With Quote
 
 
 
 
johnb
Guest
Posts: n/a
 
      31st May 2010
Hi Guys,

I can change a controls visible property at runtime using a cmd button, but
I can't seem to save the new setting when I close the Form and reopen it. The
following code works fine apart from persisting the changes
For Each ctl In frm.Controls

If ctl.ControlType = acLabel And ctl.Name = Me.GroundInFocus.Value Then
str = "I-" & Mid(ctl.Name, 1, 11)

If Me(str).Visible = True Then
Me(str).Visible = False
Me(str).Properties("Visible").Value = False
Else
Me(str).Visible = True
Me(str).Properties("Visible").Value = True
End If

End If

Next ctl
Set ctl = Nothing

Any suggestion?

TIA
johnb
 
Reply With Quote
 
johnb
Guest
Posts: n/a
 
      31st May 2010
Hi Rick
Thanks for the comments. I need to hide a label during one session of the
open Form and carry that hidden label to next Form open session. How do I
persist a hidden label over a Form closing and re-opening?

Regards
johnb

"Rick Brandt" wrote:

> johnb wrote:
>
> > Hi Guys,
> >
> > I can change a controls visible property at runtime using a cmd button,
> > but I can't seem to save the new setting when I close the Form and reopen
> > it. The following code works fine apart from persisting the changes
> > For Each ctl In frm.Controls
> >
> > If ctl.ControlType = acLabel And ctl.Name = Me.GroundInFocus.Value
> > Then
> > str = "I-" & Mid(ctl.Name, 1, 11)
> >
> > If Me(str).Visible = True Then
> > Me(str).Visible = False
> > Me(str).Properties("Visible").Value = False
> > Else
> > Me(str).Visible = True
> > Me(str).Properties("Visible").Value = True
> > End If
> >
> > End If
> >
> > Next ctl
> > Set ctl = Nothing
> >
> > Any suggestion?

>
> Changes made to a form or report in normal view via code are not supposed to
> be persisted. For that you open the form in design view.
> .
>

 
Reply With Quote
 
Dirk Goldgar
Guest
Posts: n/a
 
      31st May 2010
"johnb" <(E-Mail Removed)> wrote in message
news:709CFB09-6289-4DB3-ACDA-(E-Mail Removed)...
> Hi Rick
> Thanks for the comments. I need to hide a label during one session of the
> open Form and carry that hidden label to next Form open session. How do I
> persist a hidden label over a Form closing and re-opening?



Save, in a configuration table, the desired initial visibility of the
control. In the form's Open event, look up the value of the field in the
table and use it to set the control's Visible property.

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

 
Reply With Quote
 
johnb
Guest
Posts: n/a
 
      1st Jun 2010
Hi Dirk,
Thank you for the info. I've done just that! And it works fine. I was hoping
that I could get Access to do the work.

Regards
johnb

"Dirk Goldgar" wrote:

> "johnb" <(E-Mail Removed)> wrote in message
> news:709CFB09-6289-4DB3-ACDA-(E-Mail Removed)...
> > Hi Rick
> > Thanks for the comments. I need to hide a label during one session of the
> > open Form and carry that hidden label to next Form open session. How do I
> > persist a hidden label over a Form closing and re-opening?

>
>
> Save, in a configuration table, the desired initial visibility of the
> control. In the form's Open event, look up the value of the field in the
> table and use it to set the control's Visible property.
>
> --
> Dirk Goldgar, MS Access MVP
> Access tips: www.datagnostics.com/tips.html
>
> (please reply to the newsgroup)
>

 
Reply With Quote
 
Dirk Goldgar
Guest
Posts: n/a
 
      1st Jun 2010
"johnb" <(E-Mail Removed)> wrote in message
news:6D05A5E9-C928-4587-B4A5-(E-Mail Removed)...
> Hi Dirk,
> Thank you for the info. I've done just that! And it works fine. I was
> hoping
> that I could get Access to do the work.


The only alternative I can think of is to create a custom property of the
form and use that. However, that's not really any better than just doing
what Access is designed to do: store information in tables.

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How could I change the NavigateUrl property at runtime based on another controls property ? Radu Microsoft ASP .NET 2 25th Jan 2007 10:51 AM
Change Property on Master Page at runtime? David Lozzi Microsoft ASP .NET 4 7th Jul 2006 10:16 PM
Change MultiSelect property of ListBox during runtime =?Utf-8?B?VHJhbiBIb25nIFF1YW5n?= Microsoft Access VBA Modules 3 27th Jan 2006 01:37 PM
How to programatically change the Picture property at runtime Rob Microsoft Access Reports 5 6th Jan 2006 03:13 AM
change LimitToList Property in runtime Martin Microsoft Access Form Coding 2 26th Jul 2005 02:12 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:36 PM.