URGENT . . . PLEASE HELP ME!

somnophore

New Member
Joined
Nov 23, 2004
Messages
8
Hi,
I'm still struggerling with an old problem, in fact its been bothering me for over a month now. The problem is as follows:

I have a form that displays a question via a text box, this question can be answered yes or no.

Depending on the answer (obtained via a command button) a new question is displayed.

This works fine for the first click but then it alternates between the same two questions. The reason behind this is that it is reading the same record from the table and not actually moving to the one desired, even tho it is displaying the question.

The questions are stored in a recordset. The recordset is of four coloumns. These are the node (a identifying number), the question itself (string) and the yes and no fields (both numbers, that tell it which record to look at next).

Any idea as to where ?I am going wrong? My code for clicking on yes at the moment is as follows:

Private Sub yes_Click()
Set db = CurrentDb
Set rs = db.openrecordset("Questions")
rs.Index = "PrimaryKey"
rs.Seek "=", rs.yeslink
fquestions.Value = rs.question
End Sub

Please please help me

:pray:
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
You may already have done some of this, but...

For starters, make the form 'based' on the table you're using as a recordset. One easy way to do this is to use the wizard and select the question table as the recordsource.

Only select the question field as a field visible on the form.

Make sure you remove all dividing lines and record navigation buttons (open the form in Design mode open properties, set navigation/recordselector to no)

(basing on your method)
Create a pair of buttons, one for yes and the other for no.

In the click event for each button, put something like.

Code:
Private Sub yes_Click() 

Me.RecordSource = "SELECT * FROM Questions WHERE a = '" & Me.yes & "'"
Me.Requery

End Sub

And this in the second.

Code:
Private Sub no_Click() 

Me.RecordSource = "SELECT * FROM Questions WHERE node = '" & Me.no & "'"
Me.Requery

End Sub

This makes the assumption that your field names are "yes" and "no" AND, that you need to send a string value to the node field. If node is a number, then revise your string to remove the single quotes like:

Code:
Private Sub no_Click() 

Me.RecordSource = "SELECT * FROM Questions WHERE node = " & Me.no
Me.Requery

End Sub

What this actually does is modify the recordsource of the entire form filtering out all records that you do not need to view at this particular time.

Mike
 
Upvote 0

Forum statistics

Threads
1,221,841
Messages
6,162,314
Members
451,759
Latest member
damav78

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top