Make controls not visible if is not null field

  • Thread starter Thread starter Dave Elliott
  • Start date Start date
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.
 
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
 
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
 
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.
 
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
 
Back
Top