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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|