Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    AJ7 is offline Novice
    Windows 8 Access 2016
    Join Date
    Aug 2016
    Posts
    7

    How to control data input using checkboxes in Forms

    HI there,Let me say from the very beginning that I am a beginner user in Access 2016.

    In the form that I've created, I would like my user tick a checkbox to have another checkbox appear for them to tick (ie, if they don't tick the first check box, then the second checkbox would not appear on the form. Basically, I would like to help my user enter the information that is relevant.

    Any help would be much appreciated.

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    Using VBA code, it is possible to adjust the value of the .Visible property of controls. Additionally, where multiple choice is an option, there is something called an Option Group. The wizard can help you create multiple Radio Buttons that belong to the same Option Group.

  3. #3
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    AJ7,

    You have identified a very specific method for data entry. This what I would call a HOW. That is, How to do something and there may be options/alternatives. Quite often, instead of starting with a Form, if you create a description of what your proposed database/application is trying to accomplish in plain English, you can identify the tables involved and the relationships between them. Also, it helps readers (and you) in understanding the overall requirements and puts your "HOW" questions into context.

    Anyway, there are many ways to "skin the cat", just thought I'd refresh some general thoughts.

    Good luck with your project.

  4. #4
    AJ7 is offline Novice
    Windows 8 Access 2016
    Join Date
    Aug 2016
    Posts
    7
    Quote Originally Posted by ItsMe View Post
    Using VBA code, it is possible to adjust the value of the .Visible property of controls. Additionally, where multiple choice is an option, there is something called an Option Group. The wizard can help you create multiple Radio Buttons that belong to the same Option Group.

    Thank you very much for taking the time to reply. Sorry I am really just a beginner at this. Hence am unsure if I understood your reply. I understood you to mean to write a data Macro code? I may need a very much "dumbbed down" version of your reply.

  5. #5
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    Tell us about the proposed application. Here are a couple of examples of the sort of description I'm suggesting.

    Narrative 1
    ZYX Laboratories requires an employee tracking database. They want to track information about employees, the employee's job history, and their certifications. Employee information includes first name, middle initial, last name, social security number, address, city, state, zip, home phone, cell phone, email address. Job history would include job title, job description, pay grade, pay range, salary, and date of promotion. For certifications, they want certification type and date achieved.
    An employee can have multiple jobs over time, (ie, Analyst, Sr. Analyst, QA Administrator). Employees can also earn certifications necessary for their job.

    Class Information narrative 2
    The CIS 253 class wants to create a database to store information about the students in the class. Information will include student demographic information, contact information and course information and history.

    Information about the students will include name, address, city, state, zip, phone, email, fax, college major, Social Security Number, and gender. Each student can have more than one phone number, email address or fax number.

    Course Information includes course name, course number, number of credits, and grade received. Each student will take many courses in their college career. And naturally, each course will have many students enrolled.



    I hope the above examples help in identifying in business terms
    what data the user is going to enter into which tables?

    Good luck with your project.
    Last edited by orange; 08-21-2016 at 07:28 AM. Reason: spelling

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    As mentioned by Orange in post #5, it is important to plan ahead and build your application on a solid foundation. Doing so will help to avoid pitfalls and self-medication.

    Speaking to VBA and assigning values to the .Filter property of a control, you can do so via the VBA editor. VBA is the programming language used by Microsoft Office. Microsoft Access uses its own flavor of VBA. However, the majority of the language is common across the Office suite. When someone using Access refers to a Macro, they are referring to something other than VBA.

    Objects have various properties associated to them. The values of a control's properties determine how the control behaves. It is best to use Design View of a form or Report when working with controls. While in Design View, the property sheet is available. You can select a control in the design surface to view that specific control's properties in the Property Sheet.

    In the property sheet there is an Event tab. As the User interacts with an application, the user causes stuff to happen. Certain stuff may or may not trigger an Event. If you want to create some VBA, the best place to start would be a new blank form. While in Design View, add a Button to the design surface and cancel any prompts to use the wizard. Then, look to the Event tab in the Property Sheet to create a new Event Handler.

    Next to the Click event of a Command Control (Button), you will see an ellipses (...). Clicking it will prompt you to choose between creating a Macro, an Expression, or code using VBA. Launch the VBA editor by choosing to create VBA. Doing so will open the VBA editor and place your cursor inside your new Click Event. The cursor will be placed where your statement(s) belong. A good practice statement might be ...
    Code:
    Msgbox "Hello World!"

  7. #7
    AJ7 is offline Novice
    Windows 8 Access 2016
    Join Date
    Aug 2016
    Posts
    7
    Hi Orange, My database is a log of signals. There are different types of signals and when my user select a particular type of signal (ie, tick the first checkbox). This particular signal requires a certain (external) task to be completed. I would like the ticking of the first checkbox to trigger the appearance of a second checkbox (that would prompt the user to complete the external task and tick the second check box when the task is completed.

    Thank you for taking the time to help me.

  8. #8
    AJ7 is offline Novice
    Windows 8 Access 2016
    Join Date
    Aug 2016
    Posts
    7
    Hi Guys, I have made some headway with my situation in that I've gotten into the VBA screen. I now need some rather specific information about the exact codes to write.
    I have a checkbox "Applications" which when clicked, will trigger the appearance of another checkbox names "Assigned Sig in MIS". I have been trying a few codes: like

    If Applications.Value = True, then
    Assigned Sig in MIS.IsVisible = True

    Alas, this does not seem to work

  9. #9
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    AJ7,

    What is the subject matter of your database? What are the tables involved? Readers can help with vba once we get there. But first we need to understand WHAT you are trying to do in plain English.
    Also post a jpg of your relationships window.

  10. #10
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    When building VBA it can help to use Intellisense. For instance, when working in a form's module, you can use the Me shortcut to identify the form's properties and objects contained by the form. Simply type "Me" followed by typing ".", without the quotes.

    Maybe some code in the AfterUpdate event of your Applications control.

    Code:
    if Me![Applications].Value = True Then
    Me.Assigned_Sig_in_MIS.visible = True
    else
    Me.Assigned_Sig_in_MIS.visible = False
    End if

  11. #11
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    ItsMe has posted the solution I would have suggested for the AfterUpdate event of the checkbox. However, given the novice statement I expect AJ7 will find it won't work because I do not think you can arbitrarily insert underscores into the control name. AJ7, you should avoid spaces in names (as well as any special character - save the underscore) - and definitely don't start a name with a number. I think you will find that you need this syntax for your controls with spaces in the names: [Assigned Sig in MIS]
    Here's useful info on naming practices http://www.access-programmers.co.uk/...d.php?t=225837

  12. #12
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    IIRC, you can use dot and then the underscore. Alternatively, you can use the bang and brackets. I believe they may be interchangeable. However, I reserve using the brackets with for the bang and DAO.
    rs![SomeCollumnName]

    Then, when referencing control names ...
    Me.A_Control_Name_With_Spaces.Value

    Of course, you can use the bang and brackets. However, you may not be looking at the control and you may be looking at the field, instead.
    I do not believe the following will work
    Me![TextBoxName].Text

  13. #13
    NightWalker's Avatar
    NightWalker is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2016
    Location
    Midwest USA
    Posts
    253
    AJ,

    This is what I have that will get the results you want if they are not tied to anything in a table.

    Code:
    Private Sub form_load()
    Me.chkFirst.Value = False
    Me.chkSecond.Value = False
    Me.chkSecond.Visible = False
    End Sub
    Private Sub chkFirst_AfterUpdate()
    
    If Me.chkFirst.Value = True Then
    Me.chkSecond.Visible = True
    Else
    Me.chkSecond.Visible = False
    End If
    Me.Refresh
    End Sub
    Hope this helps
    Walker

  14. #14
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Quote Originally Posted by ItsMe View Post
    IIRC, you can use dot and then the underscore. Alternatively, you can use the bang and brackets. I believe they may be interchangeable. However, I reserve using the brackets with for the bang and DAO.
    rs![SomeCollumnName]

    Then, when referencing control names ...
    Me.A_Control_Name_With_Spaces.Value

    Of course, you can use the bang and brackets. However, you may not be looking at the control and you may be looking at the field, instead.
    I do not believe the following will work
    Me![TextBoxName].Text
    I did not know that. I know that in lieu of spaces, many use the underscore as a separator, and that if spaces are used in an object name, it has to be enclosed in square brackets. I figured that if the designer used a space in a control name (Me.[My Control]) it could not simply be replaced with Me.My_Control as you did. I guess I learned something. For those who want to know more about the bang vs dot operator, I have adopted this as gospel until somebody proves different
    http://bytecomb.com/the-bang-exclama...erator-in-vba/
    According to it, the reason for your (I believe) correct statement re Me![TextBoxName].Text, it would be because [TextBoxName] is not the default member of a form.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  15. #15
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    Yeah, that link has to be the best explanation of the bang in VBA. I have it bookmarked too.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 12-01-2015, 02:22 PM
  2. Checkboxes in Email for Collecting Data
    By pietvoerman in forum Forms
    Replies: 4
    Last Post: 07-04-2014, 12:50 AM
  3. Checkboxes in a form, how to save the data
    By alex423 in forum Forms
    Replies: 2
    Last Post: 08-12-2013, 12:28 PM
  4. Input Forms - How To Input Multiple Fields/Records?
    By butterbescotch in forum Forms
    Replies: 1
    Last Post: 04-04-2013, 06:30 AM
  5. Replies: 5
    Last Post: 01-16-2013, 03:48 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums