skevthedev
skevthedev

Reputation: 465

Access 2007 Concatinate fields based on field value

I am currently working on a database that has a series of yes and no questions in the GUI. I want to create some functionality that checks the input value against the "correct" answer specified in the logic. If the input value does not equal the "correct" answer, I want this to be noted in a DIFFERENT table in a specific field. I want this field to keep track/concatinate all incorrect answers together.

I know how this would be down with a web db like php/mysql but I am new to access and VBA scripting so any help would be greatly appreciated.

Thanks

Upvotes: 0

Views: 78

Answers (1)

Mardin Yadegar
Mardin Yadegar

Reputation: 437

The way you would check the input is like this:

    wrongAnswerConcatenation = "Questions incorrect: "
    answerEnteredByUser = me.textboxname.value
    if answerEnteredByUser = "Whatever you want correct answer to be" then
        'whatever you want to do for correct code.
    else
        wrongAnswerConcatenation = wrongAnswerConcatenation & me.textboxname.name & " "
    end if

So that is for getting the incorrect questions. This next code is to insert it into a table, make sure you have created a table before you do this.

    query = "insert into tablename(valuename) values(" & wrongAnswerConcatenation & ")"
    docmd.runsql query

This should help.

Upvotes: 1

Related Questions