Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Text box disable

Status
Not open for further replies.

bells

MIS
Oct 5, 2001
51
0
0
CA
Hello all I have the following question using Ms access 2010

I have two text boxes where depending on what is entered on the first the 2nd disabled.
that works fine
but if I make a mistake and enters a value on the 2nd while it is was enabled and return back to the first and enters a value which disable the 2nd, it disable it ok but keeps the value and even save it to the table. any idea why this is happening. thanks in advance.

Private Sub q300_AfterUpdate()

If Me.q300 = "1" Then
Me.q300_1 = ""
Me.q300_1.Enabled = False
Me.q301.SetFocus
Else
Me.q300_1.Enabled = True

End If
End Sub
 
In the underlying Table, is the Field that q300 is Bound to defined as Text or as a Number? If it's defined as a Number you need to drop the Quotation Marks.

So, if q300 is defined as a Number

Code:
Private Sub q300_AfterUpdate()

If Me.q300 = 1 Then
  Me.q300_1 = Null
  Me.q300_1.Enabled = False
  Me.q301.SetFocus
Else
  Me.q300_1.Enabled = True
End If

End Sub

If q300 is defined as Text

Code:
Private Sub q300_AfterUpdate()

If Me.q300 = "1" Then
  Me.q300_1 = Null
  Me.q300_1.Enabled = False
  Me.q301.SetFocus
Else
  Me.q300_1.Enabled = True
End If

End Sub

Hope this helps!

There's always more than one way to skin a cat!

All posts/responses based on Access 2003/2007
 

Perhaps you should clear any values in the text box before you disable it?



Randy
 
That would be what the line in red does:

Me.q300_1 = Null
Me.q300_1.Enabled = False


Hope this helps!

There's always more than one way to skin a cat!

All posts/responses based on Access 2003/2007
 

Thanks Guys

the problem was not the code. I changed the data type fro text to numbers and works very well now

thanks for all responded

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top