Apply IF statement to each record in detail of subform on load (1 Viewer)

alexcarter404

New member
Local time
Today, 21:52
Joined
Jun 12, 2013
Messages
4
Hi All,
Used to have an account on here but seem to have lost access to that, but anyway Hello and my name is Alex!

The problem I am facing is applying an IF statement to every record in the detail section of the subform.

I have the following code:

Code:
If Me.status = "CONFIRMED" Then
Me.course_ref.Enabled = False
Me.course_date.Enabled = False
Me.cmbModule1.Enabled = False
Me.cmbModule2.Enabled = False
Me.course_start_time.Enabled = False
Me.course_end_time.Enabled = False
Me.course_training_cost.Enabled = False
End If

This is in the on load event of the subform and works 'sort of'

Basically I have a record with the status of confirmed and records without this status, but the result of the if statement is being applied to all records. Is this because I need some sort of loop? and if so how would I loop through all records in the detail and apply this if statement to them all?

Any help is greatly appreciated!
Cheers,
Alex
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 13:52
Joined
Aug 30, 2003
Messages
36,139
I don't think it can be done with code. Check out Conditional Formatting.
 

alexcarter404

New member
Local time
Today, 21:52
Joined
Jun 12, 2013
Messages
4
Hi Paul,
Thanks for your reply, unfortunately I cannot use conditional formatting as I can only apply the formatting to the cell which has the value, you cannot format another field depending on another fields value.

Cheers,
Alex
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 13:52
Joined
Aug 30, 2003
Messages
36,139
Are you sure? I've done it many times. Try using Expression Is.
 

alexcarter404

New member
Local time
Today, 21:52
Joined
Jun 12, 2013
Messages
4
Hi Paul,
Thanks very much! worked like a charm! I used the expression is and put [status] = "CONFIRMED".

Cheers,
Alex
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 13:52
Joined
Aug 30, 2003
Messages
36,139
Happy to help Alex!
 

Users who are viewing this thread

Top Bottom