My Assistant
![]() ![]() |
|
|
Mar 30 2012, 11:15 AM
Post
#1
|
|
|
UtterAccess VIP Posts: 8,472 From: Dunbar,Scotland |
Hi Everyone
I want an unbound textbox named txtCancelled to display "Cancelled Member" If the Control MembershipCancelled contains a Date I tried using this in the On Load of the Form Private Sub Form_Load() If Me.MembershipCancelled = Null Then Me.txtCancelled.Visible = False Else Me.txtCancelled.Visible = True End If End Sub I also tried = "" When I navigate to any record the Cancelled control stays visible at all times Where should I place this Event??? Your help appreciated |
|
|
|
Mar 30 2012, 11:21 AM
Post
#2
|
|
|
UtterAccess VIP Posts: 8,170 From: Pacific NorthWet |
If you're relying on the contents of a field/control for a record to which the form is bound, try using the OnCurrent event.
|
|
|
|
Mar 30 2012, 11:21 AM
Post
#3
|
|
|
UtterAccess VIP Posts: 1,857 From: BC, Canada |
The reason it doesn't change is because your code is in the Form_Load event which rns when the form is loaded. To make it run each time you navigate to a new record, put it in the Form_Current event.
Mike |
|
|
|
Mar 30 2012, 11:39 AM
Post
#4
|
|
|
UtterAccess VIP Posts: 2,451 From: Downeast Maine |
And to reduce the code to one line:
Me.txtCancelled.Visible = Not (Me.MembershipCancelled = Null) |
|
|
|
Mar 30 2012, 11:42 AM
Post
#5
|
|
|
UtterAccess VIP Posts: 8,472 From: Dunbar,Scotland |
Hi Bruce
Tried this one liner:- Private Sub Form_Current() Me.txtCancelled.Visible = Not (Me.MembershipCancelled = Null) End Sub Gives me Runtime Error 94 - Invalid use of Null Any suggestions?? |
|
|
|
Mar 30 2012, 11:45 AM
Post
#6
|
|
|
UtterAccess VIP Posts: 8,472 From: Dunbar,Scotland |
Hi Bruce
Also tried this If Me.MembershipCancelled Is Not Null Then Me.txtCancelled.Visible = True Else Me.txtCancelled.Visible = False End If Gives Runtime error 424 - Object required ?? |
|
|
|
Mar 30 2012, 11:47 AM
Post
#7
|
|
|
Access Wiki and Forums Moderator Posts: 48,051 From: SoCal, USA |
Hi Mike,
What version of Access are you using? Please remember to select the version number when posting questions in case it becomes relevant to the discussion. If this is a calculated field, I recommend you don't store the value in the table. To just display something like that on the form, you can use an Unbound textbox with the following Control Source: =IIf(IsDate([MembershipCancelled]),"Cancelled Member","Active Member") Just my 2 cents... (IMG:style_emoticons/default/2cents.gif) |
|
|
|
Mar 30 2012, 11:50 AM
Post
#8
|
|
|
UtterAccess VIP Posts: 1,857 From: BC, Canada |
And to reduce the code to one line: Me.txtCancelled.Visible = Not (Me.MembershipCancelled = Null) That won't work because technically Null is not a value that can be tested, but rather it is a non-value. Try: CODE Me.txtCancelled.Visible = Not IsNull(Me.MembershipCancelled) Alternatively, I often use: CODE Me.txtCancelled.Visible = (Me.MembershipCancelled & "" <> "") Mike |
|
|
|
Mar 30 2012, 11:52 AM
Post
#9
|
|
|
UtterAccess VIP Posts: 8,472 From: Dunbar,Scotland |
Hi theDBGuy
A2010 When I used your String in an Unbound Textbox then I get this error #Name? Thoughts?? |
|
|
|
Mar 30 2012, 11:56 AM
Post
#10
|
|
|
UtterAccess VIP Posts: 8,472 From: Dunbar,Scotland |
Hi Mike
This works Me.txtCancelled.Visible = Not IsNull(Me.MembershipCancelled) Many thanks everyone for your help |
|
|
|
Mar 30 2012, 11:59 AM
Post
#11
|
|
|
Access Wiki and Forums Moderator Posts: 48,051 From: SoCal, USA |
|
|
|
|
Mar 30 2012, 12:33 PM
Post
#12
|
|
|
UtterAccess VIP Posts: 2,451 From: Downeast Maine |
Sorry about that = Null thing. I know better. I must have reverted early to my weekend brain. (IMG:style_emoticons/default/blush.gif)
|
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 23rd May 2013 - 03:37 PM |