Force record save in code

G

gdonald20

Hi

I have a problem on a sub form.

On the subform i have a button that opens a report. Obviously if the user
presses the button without moving onto the next record, the report opens
blank because the sub-form record hasn't saved.

I have tried 2 ways to fix this problem with no success so far.

Firstly on the code for the button i put in docmd.runcommand acCmdSaveRecord.

This didn't work.

Then i tried putting

If me.dirty then

me.dirty = false

End If

Now when i press the button i get the error message

"The setting you entered isn't valid for this property"

The report doesn't open and the database crashed.

Any help would be greatly appreciated.

Thanks

Gillian
 
G

gdonald20

Hi

Thanks for the reply, i tried what you suggested and i get the error

"The DoMenuItem action was cancelled"

And then the report doesn't open.

Thanks

Gillian
 
G

gdonald20

Yes i had thought about there being a problem with possibly required fields
etc, but when i tab along to the next record or move to another form and come
back the record is saved perfectly and then the report invokes correctly.

Thanks
Gillian
 
R

Rick Brandt

gdonald20 said:
Yes i had thought about there being a problem with possibly required
fields etc, but when i tab along to the next record or move to
another form and come back the record is saved perfectly and then the
report invokes correctly.

I thought that any error you would get from acCmdSaveRecord would include
WHY the record cannot be saved. That is one of the downsides to using Dirty
= False (which I prefer). That the error is not very helpful.
 

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

Top