Access 2007 New record will not save for report

itchibahn

New member
Local time
Today, 12:23
Joined
Dec 19, 2007
Messages
5
I'm having problem saving a new record from a form without closing it and open a report. Please help.

When the main form and it's subform is opened, an auto-numbered field is populated. Once the main and sub form is completely filled, a command button needs to save the record and before closing it open a report preview using that auto-numbered field. I've tried several methods to save the record when the command button is pressed but none works. The error in all methods is Syntax error (missing operator) in query expression 'AutoGeneratedID='. But it works if I close the form and reopen the form filled with that record.

Code:
    Me.Dirty = False

    Forms![frm_AddNewRecord]![Firstname].SetFocus
    DoCmd.RunCommand acCmdSaveRecord

    Form_frm_AddNewRecord.Requery

    Form_frm_AddNewRecord.Refresh

...
...    
    DoCmd.OpenReport MyReport, acPreview, , "AutoGeneratedID=" & AutoGeneratedID
 
Try this:
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "ReportName", ,"AutoGeneratedID=" & Me.AutoGeneratedID

Instead of your code.
 
Works like a charm!
You Are So Kewl!!!!
:cool::cool::cool::cool::cool::cool::cool::cool:
 

Users who are viewing this thread

Back
Top Bottom