dbTalk Databases Forums  

VB code to change Access Form Field Visibility on a record level

comp.databases.ms-access comp.databases.ms-access


Discuss VB code to change Access Form Field Visibility on a record level in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
sharsy
 
Posts: n/a

Default VB code to change Access Form Field Visibility on a record level - 04-21-2010 , 02:36 AM






Hello , I am using MS Access 2003. I have two Tables called 'Members'
and 'CRM Database', which are related via the same memberhsip number.
Basically, the CRM Database records all marketing calls made to
members.

I have created a form for Members, with a sub-form for the CRM
Database. With the CRM Database Sub-form, it displays all of the calls
made to the member. I have tried to implement some VB code so that
when a user chooses a specific drop-down option (Renewal) from a field
(Reason) for a call (an individal record), that another field (Renewal
Outcome) is displayed (and vice versa).

Here is the code I have setup:

If Me.Reason = "Renewal" Then
Me.Renewal_Outcome.Visible = True
Else
Me.Renewal_Outcome.Visible = False
End If

My problem is that when a user chooses a different drop-down option
(one that isn't Renewal) from the 'Reason' field, the 'Renewal
Outcome' field is hidden on all of the calls (even if previous calls
have been a 'Renewal' call and they have a 'Renewal Outcome' field
entry). The same is also true in reverse.

What I want to know is what code I can use so that the form field
visibility only changes on a record-level (i.e. for that call only).
At the moment, it is changing the field visibility on not only all
calls for that member, but for everyone's calls on the whole database.
This is bad because it makes it confusing for the people trying to
enter data and it also means they cannot see data already entered into
the fields for old calls, which have been hidden based on what was
selected in their latest call.

If someone could please help me that would be fabulous!!!

Thanks

Reply With Quote
  #2  
Old   
Salad
 
Posts: n/a

Default Re: VB code to change Access Form Field Visibility on a record level - 04-21-2010 , 08:44 AM






sharsy wrote:
Quote:
Hello , I am using MS Access 2003. I have two Tables called 'Members'
and 'CRM Database', which are related via the same memberhsip number.
Basically, the CRM Database records all marketing calls made to
members.

I have created a form for Members, with a sub-form for the CRM
Database. With the CRM Database Sub-form, it displays all of the calls
made to the member. I have tried to implement some VB code so that
when a user chooses a specific drop-down option (Renewal) from a field
(Reason) for a call (an individal record), that another field (Renewal
Outcome) is displayed (and vice versa).

Here is the code I have setup:

If Me.Reason = "Renewal" Then
Me.Renewal_Outcome.Visible = True
Else
Me.Renewal_Outcome.Visible = False
End If

My problem is that when a user chooses a different drop-down option
(one that isn't Renewal) from the 'Reason' field, the 'Renewal
Outcome' field is hidden on all of the calls (even if previous calls
have been a 'Renewal' call and they have a 'Renewal Outcome' field
entry). The same is also true in reverse.

What I want to know is what code I can use so that the form field
visibility only changes on a record-level (i.e. for that call only).
At the moment, it is changing the field visibility on not only all
calls for that member, but for everyone's calls on the whole database.
This is bad because it makes it confusing for the people trying to
enter data and it also means they cannot see data already entered into
the fields for old calls, which have been hidden based on what was
selected in their latest call.

If someone could please help me that would be fabulous!!!

Thanks
Do you need to use Visible? Perhaps Enabled will work as well
Me.Renewal_Outcome.Enabled = (Me.Reason = "Renewal")

Reply With Quote
  #3  
Old   
Marshall Barton
 
Posts: n/a

Default Re: VB code to change Access Form Field Visibility on a record level - 04-21-2010 , 03:50 PM



sharsy wrote:

Quote:
Hello , I am using MS Access 2003. I have two Tables called 'Members'
and 'CRM Database', which are related via the same memberhsip number.
Basically, the CRM Database records all marketing calls made to
members.

I have created a form for Members, with a sub-form for the CRM
Database. With the CRM Database Sub-form, it displays all of the calls
made to the member. I have tried to implement some VB code so that
when a user chooses a specific drop-down option (Renewal) from a field
(Reason) for a call (an individal record), that another field (Renewal
Outcome) is displayed (and vice versa).

Here is the code I have setup:

If Me.Reason = "Renewal" Then
Me.Renewal_Outcome.Visible = True
Else
Me.Renewal_Outcome.Visible = False
End If

My problem is that when a user chooses a different drop-down option
(one that isn't Renewal) from the 'Reason' field, the 'Renewal
Outcome' field is hidden on all of the calls (even if previous calls
have been a 'Renewal' call and they have a 'Renewal Outcome' field
entry). The same is also true in reverse.

What I want to know is what code I can use so that the form field
visibility only changes on a record-level (i.e. for that call only).
At the moment, it is changing the field visibility on not only all
calls for that member, but for everyone's calls on the whole database.
This is bad because it makes it confusing for the people trying to
enter data and it also means they cannot see data already entered into
the fields for old calls, which have been hidden based on what was
selected in their latest call.

That's because there is only one control with one set of
properties, it's just displayed many times. Because of that
you can not use code to affect the appearance of different
records in a continuous or datasheet form.

Instead you need to use Conditional Formating on the Format
menu to affect the appearance. Unfortunately, Visible is
not one of the CF properties. However, you can use CF to
Enable/disable the control. If you want to do that, use the
Expression Is: option on the Renewal_Outcome text box with
an expression like:
[Reason] = "Renewal"

--
Marsh

Reply With Quote
  #4  
Old   
Michiel Rapati-Kekkonen
 
Posts: n/a

Default Re: VB code to change Access Form Field Visibility on a record level - 04-24-2010 , 03:53 AM



"Marshall Barton" <marshbarton (AT) wowway (DOT) com> wrote

Quote:
sharsy wrote:

Hello , I am using MS Access 2003. I have two Tables called 'Members'
and 'CRM Database', which are related via the same memberhsip number.
Basically, the CRM Database records all marketing calls made to
members.

I have created a form for Members, with a sub-form for the CRM
Database. With the CRM Database Sub-form, it displays all of the calls
made to the member. I have tried to implement some VB code so that
when a user chooses a specific drop-down option (Renewal) from a field
(Reason) for a call (an individal record), that another field (Renewal
Outcome) is displayed (and vice versa).

Here is the code I have setup:

If Me.Reason = "Renewal" Then
Me.Renewal_Outcome.Visible = True
Else
Me.Renewal_Outcome.Visible = False
End If

My problem is that when a user chooses a different drop-down option
(one that isn't Renewal) from the 'Reason' field, the 'Renewal
Outcome' field is hidden on all of the calls (even if previous calls
have been a 'Renewal' call and they have a 'Renewal Outcome' field
entry). The same is also true in reverse.

What I want to know is what code I can use so that the form field
visibility only changes on a record-level (i.e. for that call only).
At the moment, it is changing the field visibility on not only all
calls for that member, but for everyone's calls on the whole database.
This is bad because it makes it confusing for the people trying to
enter data and it also means they cannot see data already entered into
the fields for old calls, which have been hidden based on what was
selected in their latest call.


That's because there is only one control with one set of
properties, it's just displayed many times. Because of that
you can not use code to affect the appearance of different
records in a continuous or datasheet form.

Instead you need to use Conditional Formating on the Format
menu to affect the appearance. Unfortunately, Visible is
not one of the CF properties. However, you can use CF to
Enable/disable the control. If you want to do that, use the
Expression Is: option on the Renewal_Outcome text box with
an expression like:
[Reason] = "Renewal"

--
Marsh
In a way Visibility IS a CF property, since it is about if you can see it.
If you would make the fore color the same as the back color (maybe even like
the form's back color), you can't see it any more
and hence you could call it invisible.
This one can attain with CF

Michiel


--- news://freenews.netfront.net/ - complaints: news (AT) netfront (DOT) net ---

Reply With Quote
Reply




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.