Go to first record in a table with an empty field MS Access

Posted on 2012-09-08
Last Modified: 2012-09-08
I have an Access database that has a form with a textbox on it. The textbox is for users to type answers to questions in. The user will read a question and type his or her answer in the textbox. The user will then click a command button to move on to the next question. I am allowing questions to be skipped over and returned to at a later time if an immediate answer is not available.  When the user reaches the end (there are 10 questions), he or she will click a command button to exit. Under the command button, I have code that checks if all questions have not been answered. If they haven't all been answered, a vbYesNo messagebox notifies the user that all questions have not been answered and asks him or her whether (s)he would like to continue  answering questions (vbYes) or whether (s)he would like to exit and return at a later time (vbNo).

So, under the vbYes code, I want to jump to the first unanswered question (going from 1 to 10) and place the cursor in the textbox for the user to type in an answer.

The form's record source is Table1

Table1 has 2 fields.   The first field is the QuestionNumber (all records in this field are already populated...i.e. 1 thru 10).  The second field is QuestionAnswer, which is a memo field. The control source of the textbox on the form is QuestionAnswer.

So, as an example, let's say the user answers some of the questions. The table might then look like this:

QuestionNumber         QuestionAnswer
1                                     bla bla bla                            
4                                     bla bla bla
5                                     bla bla bla

Now, let's say the user gets to the end, presses the exit button, is presented with a vbYesNo message as to whether (s)he wants to continue or not, and selects yes.   I want to then have the program jump to question number 2 (the first unanswered question in sorted order) and place the cursor in the textbox for the user to answer question number 2.  What do I put under the vbYes path to get the program to jump to the first record in the table where the QuestionAnswer field is blank? Thank you.
Question by:dbfromnewjersey
    LVL 29

    Accepted Solution

    Try this:
    Me.Recordset.FindFirst "[QuestionNumber] is Null"

    Author Comment


    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    This isn't a frequent question on EE. I must have seen it three or four times (among several thousand questions). However, I use this trick quite often, most frequently as a delayed Current event. A form does not expose it's calculation dependenc…
    I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
    Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    754 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

    24 Experts available now in Live!

    Get 1:1 Help Now