Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / December 2006

Tip: Looking for answers? Try searching our database.

Base on text box from selection of another on form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
slagg7575@hotmail.com - 29 Dec 2006 16:38 GMT
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
Klatuu - 29 Dec 2006 18:20 GMT
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        
   

> Hi All,
>
[quoted text clipped - 3 lines]
>
> Slagg
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.