E
Evi
Hi all
I have Access 2000.
My database is a questionaire. The main form is the person taking the
questoinaire. The first subform FrmPersonAnswerSub - a single form linked to
the MainForm- holds the questions.
The second subform FrmPersonAnswerSub2 - linked to the first subform,
presents multi-choice answers for the user to select from.
A button on the main form, cmbNextQuestion moves to the next record.
The code works until I reach the last record, correctly reading a field in
FrmPersonAnswerSub. But it doesn't spot the EndOfFile and tries to move the
next record, giving me a No Current Record error.
What have I done wrong.
Private Sub cmbNextQuestion_Click()
Dim frm As Form
Dim rst As DAO.Recordset
Dim MySub As Control
Dim MyAnsType As Integer
Set frm = Me.FrmPersonAnswerSub.Form
Set rst = frm.RecordsetClone
MsgBox frm.RecordsetClone.RecordCount
'works correctly, counting the correct number of records
If Not rst.EOF Then
'doesn't recognize this bit.
rst.MoveNext
frm.Bookmark = rst.Bookmark
MyAnsType = rst!QuestID
MsgBox MyAnsType
'code correctly reads QuestID field in the first subform
Me.FrmPersonAnswerSub2.Requery
'requery second subform which is linked to the first subform
Else
'the code never gets to this next bit
MsgBox "That was the last question"
Me.SurvEndDate.SetFocus
'so that I can disable the NextQuestion button
Me.cmbNextQuestion.Enabled = False
Me.SurvEndDate = Date
Set frm = Nothing
Exit Sub
End If
Set rst = Nothing
Set frm = Nothing
End Sub
Evi
I have Access 2000.
My database is a questionaire. The main form is the person taking the
questoinaire. The first subform FrmPersonAnswerSub - a single form linked to
the MainForm- holds the questions.
The second subform FrmPersonAnswerSub2 - linked to the first subform,
presents multi-choice answers for the user to select from.
A button on the main form, cmbNextQuestion moves to the next record.
The code works until I reach the last record, correctly reading a field in
FrmPersonAnswerSub. But it doesn't spot the EndOfFile and tries to move the
next record, giving me a No Current Record error.
What have I done wrong.
Private Sub cmbNextQuestion_Click()
Dim frm As Form
Dim rst As DAO.Recordset
Dim MySub As Control
Dim MyAnsType As Integer
Set frm = Me.FrmPersonAnswerSub.Form
Set rst = frm.RecordsetClone
MsgBox frm.RecordsetClone.RecordCount
'works correctly, counting the correct number of records
If Not rst.EOF Then
'doesn't recognize this bit.
rst.MoveNext
frm.Bookmark = rst.Bookmark
MyAnsType = rst!QuestID
MsgBox MyAnsType
'code correctly reads QuestID field in the first subform
Me.FrmPersonAnswerSub2.Requery
'requery second subform which is linked to the first subform
Else
'the code never gets to this next bit
MsgBox "That was the last question"
Me.SurvEndDate.SetFocus
'so that I can disable the NextQuestion button
Me.cmbNextQuestion.Enabled = False
Me.SurvEndDate = Date
Set frm = Nothing
Exit Sub
End If
Set rst = Nothing
Set frm = Nothing
End Sub
Evi