A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Base on text box from selection of another on form



 
 
Thread Tools Display Modes
  #1  
Old December 29th, 2006, 05:38 PM posted to microsoft.public.access.forms
[email protected]
external usenet poster
 
Posts: 23
Default Base on text box from selection of another on form

Hi All,

Easy question here, I have on text box called Smoking, and if NO, i
need textbox-Years Smoked to be 'NA' , otherwise, if YES, the user will
enter the rest of the data for years smoked. How is this done? Thanks!

Slagg

  #2  
Old December 29th, 2006, 07:20 PM posted to microsoft.public.access.forms
Klatuu
external usenet poster
 
Posts: 7,074
Default Base on text box from selection of another on form

What is the data type of the table field bound to the Years Smoked text box?
It probably should be either an Interger or a Long. In this case, 'NA' would
not be accepted in the table. If it is not a number, then you may have a
problem using it in calculations.

I would not use a text box for a Yes/No answer. I would suggest a check
box. No reason for a user to have to type in a Yes or No and no reason for
you to have to validate that a good answer was typed in.

I would make all the controls related to smoking Locked in design view and
only unlock them if the Smoking check box is checked.

If you do this, don't forget to change the data type of the table field
bound to the Smoking check box from text to Boolean (Yes/No).

Now, to make it work, use the After Update event of the check box:

Private Sub chkSmoking_AfterUpdate()

With Me
If .chkSmoking = True Then
.[Years Smoked].Locked = False
.OtherControlsForSmoking.Locked = False
.[Years Smoked].SetFocus
Else
.[Years Smoked] = 0
End If
End With
End Sub

And to keep it in sync with current records, use the form's Current event:

With Me
If .chkSmoking = True Then
.[Years Smoked].Locked = True
.OtherControlsForSmoking.Locked = True
Else
.[Years Smoked].Locked = False
.OtherControlsForSmoking.Locked = False
End If

" wrote:

Hi All,

Easy question here, I have on text box called Smoking, and if NO, i
need textbox-Years Smoked to be 'NA' , otherwise, if YES, the user will
enter the rest of the data for years smoked. How is this done? Thanks!

Slagg


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:56 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.