Code error: goto newly added Record

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
 
P

Pieter Wijnen

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
 

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

Similar Threads


Top