Making Label on Form Visible or Not Visible based on Date Field Value

Gigitty

Member
Local time
Yesterday, 21:34
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

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
 
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?
 
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

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
 
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!
 
Try [Date In] >= #1/1/2023#
 
Make sure the backstyle is Normal not Transparent. That syntax works for me, I tested it.
 
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
 
I've taken another approach and solved the issue. Thankyou to everyone for your responses.
 
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.
 
I think the formula you want is

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

Users who are viewing this thread

Back
Top Bottom