Make controls not visible if is not null field

D

Dave Elliott

I have a form named FReg that is a Check Register, you can enter credits or
debits
I dont want the user to be able to do both on the same record.
If the user enters a debit then the credit field should be dimmed or
invisible. The first control they go to is. (debit) not (Credit)
On exit of the control debit I wish it to make (2) controls invisible if
there is data in the debit field.
One control is (Depositor) and the other is (Credit)
How can I do this?
I tried this code, but didnt work:

If Not IsNull(debit) Then
Depositor.Visible = False
credit.Visible = False
Else: Depositor.Visible = True
credit.Visible = True

End If



Thanks for your help.
 
K

Ken Snell

Use the AfterUpdate event of Debit to run the code:

Private Sub Debit_AfterUpdate()
Me.Depositor.Enabled = (Len(Me.Debit & "") = 0)
Me.Credit.Enabled = (Len(Me.Debit & "") = 0)
End Sub
 
D

Dave Elliott

The control credit still remains enabled and show this $0.00
There is no default amount for the control credit.
The other control depositor works fine
 
D

Dave Elliott

Ok, it is working, so how do I now make it go back (Not Dim) after leaving
this record?
The last control on this record is Memo.
If I close the form and repoen it of course does not dim until you update
the debit control.
 
K

Ken Snell

Add code to the OnCurrent event of the form so that the controls' properties
are set for each record:

Private Sub Form_Current()
Me.Depositor.Enabled = (Len(Me.Debit & "") = 0)
Me.Credit.Enabled = (Len(Me.Debit & "") = 0)
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top