On Save of new record, screen jumps to another record.

G

Guest

Hello, I have an access 97 application that uses a bound form. In the past I
would
use
DoCmd.DoMenuItem acFormBar, acFile, acSaveRecord on the click event of a
button that would save and close the screen. This worked fine.

I changed to have the ability to just save while on the screen and not close
it. For a new record, it will correctly save the record but the screen jumps
to a different row in the query. Why would this be happening? Initially the
form was linked to a multiple table query but I switched it to directly go
against one table and I get the same results.

Thanks

Don
 
D

Dirk Goldgar

Don said:
Hello, I have an access 97 application that uses a bound form. In
the past I would
use
DoCmd.DoMenuItem acFormBar, acFile, acSaveRecord on the click event
of a button that would save and close the screen. This worked fine.

I changed to have the ability to just save while on the screen and
not close it. For a new record, it will correctly save the record
but the screen jumps to a different row in the query. Why would this
be happening? Initially the form was linked to a multiple table
query but I switched it to directly go against one table and I get
the same results.

Although I haven't checked it out in detail, I strongly suspect that
you're using the wrong menu items. These are easy to get confused,
since you're dealing with defined constants that have different effects
depending on where they're used. I suggest you use the appropriate
RunCommand or DoCmd methods instead of DoMenuItem, since these are
unambiguous.

To save the current record:

RunCommand acCmdSaveRecord

To save the record and close the form:

RunCommand acCmdSaveRecord
DoCmd.Close acForm, Me.Name

Although, since the record will be saved if possible (and if necessary)
when the form is closed, you could just write:

DoCmd.Close acForm, Me.Name
 
G

Guest

That still gives me the same issue.

Dirk Goldgar said:
Although I haven't checked it out in detail, I strongly suspect that
you're using the wrong menu items. These are easy to get confused,
since you're dealing with defined constants that have different effects
depending on where they're used. I suggest you use the appropriate
RunCommand or DoCmd methods instead of DoMenuItem, since these are
unambiguous.

To save the current record:

RunCommand acCmdSaveRecord

To save the record and close the form:

RunCommand acCmdSaveRecord
DoCmd.Close acForm, Me.Name

Although, since the record will be saved if possible (and if necessary)
when the form is closed, you could just write:

DoCmd.Close acForm, Me.Name

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
D

Dirk Goldgar

Hmm. I suspect the operation of code or a macro in the form's
AfterUpdate event. Please post the complete code from the form's code
module.
 
G

Guest

Dirk, Thanks for the suggestion, I finally traced the problem to a trigger
running on the table.
 

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