Solved using if statement on continous form (1 Viewer)

kobiashi

Registered User.
Local time
Today, 18:22
Joined
May 11, 2018
Messages
258
i have two fields on a continous form, reason im using a continous form is so i can use a delete entry button.

CbxEventTracker and CbxNonEventTracker

when the CbxEventTracker has an entry, i want to grey out the CbxNonEventtracker field

this is what i used

Code:
Private Sub CbxEventTracker_AfterUpdate()
    If Not IsEmpty(Me!CbxEventTracker.Value) Then
        Me!CbxNonEventTracker = "20"
        Me!CbxNonEventTracker.BackColor = RGB(156, 156, 156)
        Me!CbxNonEventTracker.Locked = True
    End If
End Sub


It does work, but the problem is it locks all the other rows out aswell, so how do i make it only effect one row at a time?
 

June7

AWF VIP
Local time
Today, 10:22
Joined
Mar 9, 2014
Messages
5,423
Have to use Conditional Formatting. No VBA needed.
 

kobiashi

Registered User.
Local time
Today, 18:22
Joined
May 11, 2018
Messages
258
Have to use Conditional Formatting. No VBA needed.
thanks for your reply, could you elaborate of give an exmple please, im not sure how it would work
 

kobiashi

Registered User.
Local time
Today, 18:22
Joined
May 11, 2018
Messages
258
its ok ive sorted it now, thanks for the pointer
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 14:22
Joined
Feb 19, 2002
Messages
42,971
Conditional formatting will work better for this situation but FYI, when you want to make one field dependent on another, you must have code in the Current event as well as the AfterUpdate event of the control. Otherwise, the properties will not be set correctly for existing records. Rather than repeat code in two places, I usually create a procedure and call it from both event procedures.

And finally, A continuous form (or one in DS view) has only a single set of propertes ant they apply to all visible rows. That's why it "looks" like all the rows are locked but if your code had been also in the Current event, the rows would have "unlocked" when you moved focus to a row where the controls should have been unlocked. only ONE row can be Current at one time so no other row can be updated anyway. It is a visual thing but not a problem.
 

Users who are viewing this thread

Top Bottom