if find record

J

Jake F

I'm creating a survey and need all questions answered. I've figured out how
to have a goto acLast button go to the last record that has not been
answered, but in doing so, did not account for what to do if all records have
been answered and you still want to go to the last one if you were reviewing
some. I was thinking that the If docmd.findrecord = true would work, but I
need a variable or function I guess.

Private Sub cmdLast_Click()
On Error GoTo Err_cmdLast_Click
If QstnNbr = 33 Then
MsgBox "You are currently at the last question.", vbOKOnly, "Safety
Survey"
End If
If Rspns = "Unanswered" Then
MsgBox "All questions must be answered.", vbOKOnly, "Safety Survey"
End If
If DoCmd.FindRecord("Unanswered", , True, , True, acAll) = True Then
DoCmd.FindRecord "Unanswered", , True, , True, acAll
Else
DoCmd.GoToRecord , , acLast
End If
Exit_cmdLast_Click:
Exit Sub
Err_cmdLast_Click:
MsgBox Err.Description
Resume Exit_cmdLast_Click
End Sub
 
M

Michel Walsh

If there are 40 questions and if an un-answered question has a null value in
its Answer field, then:

if 40 = DCOUNT("Answer", "tableNameHere", "WhoID=" & IDofWhoAnswering) then
... all questions have an answer
else
... some question have no answer
end if



Note that the third argument of the DCount is not required if you table
holds answer of just one person.

DCount( "fieldName", ... ) returns the number of records having a NOT NULL
value under the given fieldname.


Vanderghast, Access MVP
 
J

Jake F

Thanks! It works perfectly!

Michel Walsh said:
If there are 40 questions and if an un-answered question has a null value in
its Answer field, then:

if 40 = DCOUNT("Answer", "tableNameHere", "WhoID=" & IDofWhoAnswering) then
... all questions have an answer
else
... some question have no answer
end if



Note that the third argument of the DCount is not required if you table
holds answer of just one person.

DCount( "fieldName", ... ) returns the number of records having a NOT NULL
value under the given fieldname.


Vanderghast, Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top