Making Label on Form Visible or Not Visible based on Date Field Value (1 Viewer)

Gigitty

Member
Local time
Today, 00:28
Joined
Mar 29, 2007
Messages
52
Hi gang.

Trying to make the label 'Device Available' not visible if the 'Date In' field is not blank using code. Can anyone help out? Thanking you in advance. (screen shot attached)
 

Attachments

  • Holter Screen Shot.pdf
    44.7 KB · Views: 57

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 02:28
Joined
Feb 28, 2001
Messages
27,191
Since we don't know the field names involved, this will be sample code.

First, you have to choose where to put this code. Probably the best place is the Form_Current routine, but I could be wrong if special circumstances apply to your situation. Assuming normal situation,

(somewhere within Form_Current)

Code:
IF NZ( [Date In], "" ) <> "" THEN
    [Device Available].Visible = TRUE
END IF
 

Gigitty

Member
Local time
Today, 00:28
Joined
Mar 29, 2007
Messages
52
Since we don't know the field names involved, this will be sample code.

First, you have to choose where to put this code. Probably the best place is the Form_Current routine, but I could be wrong if special circumstances apply to your situation. Assuming normal situation,

(somewhere within Form_Current)

Code:
IF NZ( [Date In], "" ) <> "" THEN
    [Device Available].Visible = TRUE
END IF
Sorry what does the 'NZ' refer to?
 

Gigitty

Member
Local time
Today, 00:28
Joined
Mar 29, 2007
Messages
52
i've attached a copy of the database here, free of any data.
Since we don't know the field names involved, this will be sample code.

First, you have to choose where to put this code. Probably the best place is the Form_Current routine, but I could be wrong if special circumstances apply to your situation. Assuming normal situation,

(somewhere within Form_Current)

Code:
IF NZ( [Date In], "" ) <> "" THEN
    [Device Available].Visible = TRUE
END IF
 

Attachments

  • Holter Monitor Device Log.accdb
    504 KB · Views: 60

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 15:28
Joined
May 7, 2009
Messages
19,245
you can change the label to textbox and add Conditional Format.
 

Attachments

  • Holter Monitor Device Log.accdb
    608 KB · Views: 59

CJ_London

Super Moderator
Staff member
Local time
Today, 08:28
Joined
Feb 19, 2013
Messages
16,616
Conditional Format doesn't allow me to format based on the data value of another field.
yes it does - the format is determined based on a condition - which could be the value of another field.

Use the Expression Is option
 

isladogs

MVP / VIP
Local time
Today, 08:28
Joined
Jan 14, 2017
Messages
18,235
Conditional Format doesn't allow me to format based on the data value of another field.

Yes it does! Use Expression Is instead of Field Value is e.g.

1673344960768.png


Oops. CJ_L beat me to it!
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 03:28
Joined
May 21, 2018
Messages
8,529
Try [Date In] >= #1/1/2023#
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 03:28
Joined
May 21, 2018
Messages
8,529
Make sure the backstyle is Normal not Transparent. That syntax works for me, I tested it.
 

Gigitty

Member
Local time
Today, 00:28
Joined
Mar 29, 2007
Messages
52
I managed to get it working using VBA with the label. Only issue I now need to figure out is to apply it to each record individually as the data in the first record is affecting the label on all remaining 12 records. Would this be due to it being a 'Continuous Form'?

1673399733778.png
 

Gigitty

Member
Local time
Today, 00:28
Joined
Mar 29, 2007
Messages
52
I've taken another approach and solved the issue. Thankyou to everyone for your responses.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 02:28
Joined
Feb 28, 2001
Messages
27,191
as the data in the first record is affecting the label on all remaining 12 records. Would this be due to it being a 'Continuous Form'?

Yes.

Sorry what does the 'NZ' refer to?

NZ is the "NullZero" function which tests the input for being a null (something that Access really doesn't like) and allows you to substitute a value for the null. The syntax in the code snippet I offered in post #2 shows how you use it.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 08:28
Joined
Feb 19, 2013
Messages
16,616
I think the formula you want is

Expression is......isnull([date in])=false
 

Users who are viewing this thread

Top Bottom