Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DoCmd - Help 1

Status
Not open for further replies.

dorinda

Programmer
Jan 30, 2003
6
GB
Hi, my problem is that i have an Access database which makes use of the command buttons assocaited with docmd
eg. DoCmd.GoToRecord , , acNext.
I've come to realise that any changes made to the records displayed on my form will be automatically saved.

I have been asked to put in 2 search buttons so the user can search for a specific record, then after this point, can use the forward and backward command buttons to navigate throughout the rest of the recordset.
I did this using SQL statements to produce a recordset, and when the user hits the search buttons these are used rather than the docmd code..

The problem is when the user closes the form, it automatically wants to save the current record displayed, but since it is already in the database it produces a msgbox stating there cant be duplicate values etc

Could anyone suggest anyway round this?? or how can i make it not save when exiting??

I hope i've made this clear, but having thought about it for the past few days my brain is broke!

 
Yes i do have warnings set to false in one the of the search buttons - but if they are set to false would it then mean it wouldnt display the message?

I commented them out and tried it there and it still comes up with the same message..
 
Hi, thanks for the speedy replies!

I put your suggested code into the
Private Sub Form_Close()
DoCmd.RunCommand (acCmdUndo)

A runtime error occurs '2046'
'The command or action 'undo' is not available now'

I put a code break at this method, and the message box saying about duplicate values is displayed before this method is called.
 
try attaching it to a button rather than the form_close event
ex
ButtonClose_Click()
DoCmd.RunCommand (acCmdUndo)
Docmd.close

 
Hi, thanks for that suggestion - for some reason the acCmdUndo wouldnt work, but taking it out and leaving the DoCmd does work.
I have finally solved my inital problems by using
SQL = [SQL Code]
me.recordsource = SQL
me.requery ..rather than using different recordsets at once, for anyone who has a similar problem!

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top