TabControl

  • Thread starter Thread starter Nad
  • Start date Start date
N

Nad

Hi guys!
I put a tab control on my form with two pages.Recordsource of the form a
table.
I put two fields TecoDate & Budget from the table on two different page of
the tab control.
I wrote the below code in the Form Load Event to lock the textbox if there
is any data (to prevent users to change already filled data , if there is no
data they can put the data)
If Me.TxtTecoPlanDate.Value <> " " Then Me.TxtTecoPlanDate.Locked = True
If Me.TxtBudget.Value <> " " Then Me.TxtBudget.Locked = True
But the problem is that when i open the form it locks the textbox even if
there is no data (Locked for all).
Please advice.
 
Hi

There are a few ways to do this but most likely the simplest would be be to
put a little code on the GotFocus event of the control

something like

Private Sub TxtTecoPlanDate_GotFocus()
If Not IsNull(Me.TxtTecoPlanDate) Then
Me.TxtTecoPlanDate.Locked = True
Else
Me.TxtTecoPlanDate.Locked = False
End If
End Sub

As I said there's a number of methods but this seems to be a really simple way
 
The problem is your test logic.
The control will likely never have a value of " "
It will either be Null or an empty string.

This is the typical check for what you are doing:

Me.txtTecoPlanDate.Locked = Trim(Me.txtTecoPlanDate & " ") & Null

Also, the form load event is not the correct event. That will fire only for
the first record when the form is loaded. Use the form Current event. It
fires for each record.
 
Many Thanks to both of you ' Sir ' for responce & advice.
Now i will follow your advice.

Best Regards,
 
Back
Top