in Education by
I am new to VBA and I'm trying to create a form in Access where a text box is enabled or disabled based on whether a check box is checked or unchecked. So if the 'Survey Requested?' box is checked the 'Date Survey Requested' box is enabled for the user to enter a date. I have the following code: Private Sub CheckSurveyRequested_AfterUpdate() If CheckSurveyRequested = True Then DateSurveyReq.Enabled = True Else DateSurveyReq.Enabled = False End If End Sub But this comes up with a '424 Object Required' error when I run line 5. Anyone have a suggestion as to what I'm doing wrong here? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
You should definitely use the AfterUpdate event---tying the behavior of your textbox to the click event means that a user using their keyboard to navigate the form won't get the same behavior. Also, you should replicate this behavior when the form loads: If the default value for the checkbox is False, then your textbox should be disabled when the form loads. Also, as @ErikA notes, you can do this with one readable line. So I would recommend something like this: Option Explicit Private Sub chkSurveyRequested_AfterUpdate() Me.txtDateSurveyReq.Enabled = Me.chkSurveyRequested.value End Sub Private Sub Form_Load() Me.txtDateSurveyReq.Enabled = Me.chkSurveyRequested.value End Sub In order to not repeat yourself, you could move this code into a separate sub: Option Explicit Private Sub Form_Load() ' assign the function below to the AfterUpdate event of the checkbox. Me.chkSurveyRequested.AfterUpdate = "=UpdateControls()" ' now execute the function directly UpdateControls End Sub Private Function UpdateControls() Me.txtDateSurveyReq.Enabled = Me.chkSurveyRequested.value End Function

Related questions

0 votes
    I have two forms: frmClient', (which has a subform that lists applicants), and frmDisclosure', which ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 17, 2022 in Education by JackTerrance
0 votes
    I am receiving the error "'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine" ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 16, 2022 in Education by JackTerrance
0 votes
    Microsoft has chosen to not release a 64-bit version of Jet, their database driver for Access. Does anyone ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 22, 2022 in Education by JackTerrance
0 votes
    Microsoft has chosen to not release a 64-bit version of Jet, their database driver for Access. Does anyone ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 21, 2022 in Education by JackTerrance
0 votes
    If you see jqGrid demo : http://www.trirand.com/blog/jqgrid/jqgrid.html Section : Advanced --> ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 11, 2022 in Education by JackTerrance
0 votes
    If you see jqGrid demo : http://www.trirand.com/blog/jqgrid/jqgrid.html Section : Advanced --> ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 10, 2022 in Education by JackTerrance
0 votes
    This script extracts data from check boxes in order to determine the information a form sends to PayPal. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Aug 1, 2022 in Education by JackTerrance
0 votes
    When is it appropriate to use a class in Visual Basic for Applications (VBA)? I'm assuming the ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 17, 2022 in Education by JackTerrance
0 votes
    Does a tinymce plone plugin exist for this? I've done a quick search and come up empty. JavaScript ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 12, 2022 in Education by JackTerrance
0 votes
    What is the easiest way to call a web service from Excel (I am using version 2002)? Please, no ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 21, 2022 in Education by JackTerrance
0 votes
    What is the easiest way to call a web service from Excel (I am using version 2002)? Please, no ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    In my UITableView, i need to get the event of the user, so when the cell is selected(checked), i ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Aug 1, 2022 in Education by JackTerrance
0 votes
    I have a,b,c in a table with check boxes I want by clicking sub button echoing value of checkboxes that are checked...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    I wrote the following code to quickly grab and display information from Wikipedia. It works great unless the ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 13, 2022 in Education by JackTerrance
0 votes
    The Problem is simple, The below shown is an input text box. i've set the value of the input box ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 27, 2022 in Education by JackTerrance
...