Records inside a form (1 Viewer)

rwahdan

New member
Local time
Today, 05:33
Joined
Feb 11, 2006
Messages
9
Hi,

I am using DAO to get the records from table. I have a form that has text fields to enter the records. I have a button called Next Record and i need it to show next record in recordset in the same form using same textboxes.
 

Cronk

Registered User.
Local time
Today, 22:33
Joined
Jul 4, 2013
Messages
2,772
docmd.runCommand acCmdRecordsGotoNext

Any reason you don't want to use the inbuilt navigation provided with the form?
 

rwahdan

New member
Local time
Today, 05:33
Joined
Feb 11, 2006
Messages
9
docmd.runCommand acCmdRecordsGotoNext

Any reason you don't want to use the inbuilt navigation provided with the form?

Thanks for the reply, the reason is I am making an exam engine and i want to view next question which is in the record set.

That didn't work as i am loading data on form load, when i click on button then i need to go to next record in the table, how can this be done?

Thanks

Code:
Private Sub Form_Load()

Dim db1 As DAO.Database
Dim rst1 As DAO.Recordset
Dim db2 As DAO.Database
Dim rst2 As DAO.Recordset
Dim gradeid As Integer

Set db2 = CurrentDb

    Set rst2 = db2.OpenRecordset("SELECT * FROM grade4MultiQuestions")
    question.Caption = rst2!question
    gradeid = rst2!grade4MultiID
    
    
Set db1 = CurrentDb

    Set rst1 = db1.OpenRecordset("SELECT * FROM grade4MultiAnswers where grade4MultiQuestionsID = " & gradeid & "")
    answer1.Caption = rst1!answer3
    answer2.Caption = rst1!answer1
    answer3.Caption = rst1!answer2
    lblcorrect.Caption = rst1!correctAnswer

End Sub
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 07:33
Joined
Feb 28, 2001
Messages
27,179
Consider that if you look at Me.Recordset.Clone, you can do recordset operations on that copy of the form's intrinsic recordset. You can do a Me.Recordset.Clone.MoveNext or you can assign a recordset variable such as

Code:
Set RSClone = Me.Recordset.Clone
RSClone.MoveNext
X = RSClone![fieldname]
etc. etc.

That would enable you to use the form for normal things and the clone for previewing whatever it is that you want to preview.
 

Mark_

Longboard on the internet
Local time
Today, 05:33
Joined
Sep 12, 2017
Messages
2,111
What problem did you have with using the normal record source for your form?
 

Users who are viewing this thread

Top Bottom