Change value in label when textbox value changes

Posted on 2012-09-11
Last Modified: 2012-11-16
I have an Access table with 5 records and 2 fields.  Currently, Field1 is populated with the record number and Field2 is blank. It looks like this:

Field1     Field2

I have an Access form that has a textbox on it for the user to type in an answer to each of 5 questions.  I have Next Record and Previous Record command buttons on the form. I want each question displayed in a label (unless there is a better way of doing this) depending on what record number the user is on.  So, if a user is on record #1, I want question #1 displayed in the label. If the user clicks the Next Record button, I want question #2 displayed in the label, etc.  I thought of saving the questions in a table but because I need to format them (some words in a question need to be italic, etc), I figured I'd just hard code the questions in the code window and display them in the label depending on what record the user is on. On my form (which has MyTable as its record source), I have a textbox whose control source is Field1 of the table, so that control can be referenced to know which record the user is currently on.  How do I get the correct question to display in the label based on what record number the user is on? Thank you.
Question by:dbfromnewjersey
    1 Comment
    LVL 61

    Accepted Solution

    Assuming that your form is in Single Form view, you can do this in the Current Event of your form:

    Select Case Me.Field1
            Case 1:
                     Me.lblQuestion.Caption  = "question 1"
            Case 2:
                     Me.lblQuestion.Caption  = "question 2"
            Case 3:
                     Me.lblQuestion.Caption  = "question 3"
    ' etc
    End Select

    Open in new window


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    In the article entitled Working with Objects – Part 1 (, you learned the basics of working with objects, properties, methods, and events. In Work…
    A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
    In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
    In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now