copying field value to a new table

  • Thread starter Thread starter Ian Rhodes
  • Start date Start date
I

Ian Rhodes

I have created a table with a list of questions to represent a
flowchart using yes or no selection from command buttons. When the
button is clicked the form jumps to the record that corresponds to the
selection criteria i.e.

Question 1 = are you in pain
Command button Yes click = goto question 10
Command button No click = goto question 3.

Because not every question will be asked I am not using yes/no field
types. What I want to do is copy the current record field question in
to a new table with field Question Asked and a field Answer using a
string constant representing Yes or No depending on which button is
pressed.

Being new to this I am trying to get there in the most direct route
without creating a lot of unecessary actions.

Any help and advice appreciated
 
If you are using a label for the question and click buttons for the
Yes and No answer, then you can do something like this:

AIR CODE

Dim db as database
Dim txtAnswer as string
Dim txtQuestion as string
dim SQLString as String


'In the click button for Yes
txtQuestion = Me!LabelName.Caption
txtAnswer ="Yes"

'In the click button for No
txtQuestion = Me!LabelName.Caption
txtAnswer ="No"

Then at some point in your program, you can do:

Set db=CurrentDB
SQLString = "INSERT INTO tblAnswers (UserID, Answer, Question) VALUE "
SQLString = SQLString & " ('" Me!UserName & "', '" & txtAnswer & "', "
SQLString = SQLString & "'" & txtQuestion & "');"

dbs.Execute SQLString

If the user is selection the question from a ListBox, then in the
AfterUpdate of the Listbox, you can do this:

txtQuestion = Me!ListControl.Column(0)
or
txtQuestion = Me!ListControl.Column(1)

Depending on the column the question is in in the list box.

Ron
 
Back
Top