Code error: goto newly added Record

  • Thread starter Thread starter Kaur
  • Start date Start date
K

Kaur

Hi,

I would appriceate any help to correct the code error that I am getting
for the onclick event of a cmd button. I have two forms. Main Form
"frmQuestion" and form 2 "SfrmQuestion". FrmQuestion shows the details
about Question and by clicking on one for the cmd button on this form
opens up SfrmQuestions that lets me add new questions. The frmQuestion
Form remains opened at the backend. My problem is when I save the
question in srmQuestion I want to go to the same added record in
frmQuestion by clicking on saveRecord cmd button which closes the
sfrmquestion Form. This is the code I have in sfrmQuestion's cmdbutton
cmdSaveRecord. I keep on getting an error

Private Sub cmdSaveRecord_Click()
DoCmd.Save
'Dim rs As DAO.Recordset

With Forms![frmQuestion]
..Requery
Set rs = Forms![frmQuestion].RecordsetClone

rs.FindFirst "QuestionID = " & Me.QuestionID
If rs.NoMatch Then
MsgBox "Not found."
Else
rs.Bookmark = Me.Bookmark
End If
Set rs = Nothing
End With

DoCmd.Close



End Sub
 
Don't Use Docmd.Save (it saves the form! not the record)

Use DoCmd.SaveRecord
Or
better still:

If Me.Dirty Then Me.Dirty=False

HTH

Pieter
 
Back
Top