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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access 2007 - close buttons 3

Status
Not open for further replies.

integritycare

Technical User
Mar 12, 2011
151
AU
Hello,
After upgrading access 2003 database to access 2007, the close buttons on forms will not work.
I have searched the forums and used the Trust Center to add the folder to the Trusted Locations. But still no joy.
What is the answer to this please.

Many thanks,

Integrity
 
What is the code behind your close button(s)?

"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57
 

Hello kjv1611
This is the code that worked on all the forms in access2003

Code:
Private Sub Closed_Click()
On Error GoTo Err_Closed_Click


    DoCmd.Close

Exit_Closed_Click:
    Exit Sub

Err_Closed_Click:
    MsgBox Err.Description
    Resume Exit_Closed_Click
    
End Sub

Regards

Integrity
 
will not work
Well, what happens ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hello PHV
Exactly nothing. Had no issues with the db in access 2003, but now its been converted to Access 2007 this has been the result.
Might have to try converting the database again. But the close button on the control box will close forms ok.

Integrity
 
What about this ?
DoCmd.Close acForm, Me.Name

BTW, did you try to set a breakpoint in your code ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Another question: Even though you set your location of your database to a trusted location, when you open it, do you get a yellow bar at the top saying something about some code may not run? If so, then the code will not run until you resolve that. One easy way is to allow all macros in Access, or else just click the "Enable Content" button on the yellow bar each time you open the database...

"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57
 
Hi Guys,
Well I did what I said I would do.. I set up a new Db and re-imported the Access 3003 Database.
Now all the forms will close as they should. Don't know if this will last of course..
Integrity
 
You really should use the other parameters of the close method that PHV shows. Without specifying the name of the object to close you can create a lot of situations where the wrong object closes.
 
Hi MajP,
Thanks for that info I will folllow what PHV has said.

Integrity
 
Also note that it has long been recommended that the code

DoCmd.RunCommand acCmdSaveRecord

or

If Me.Dirty Then Me.Dirty = False

be inserted before using

DoCmd.Close

to close a Form because of a quirk in Access. When DoCmd.Close is used, Access closes the Form regardless of whether or not a PK field or other Required Field has been left blank or validation rules have been violated!

If one of these things occur, Access will simply dump the Record, Close the Form, and not tell the user that the Record has been dumped!

The code If Me.Dirty Then Me.Dirty = False or DoCmd.RunCommand acCmdSaveRecord
forces Access to attempt to Save the Record, and if a violation has occurred, will throw up a warning message, allowing correction to be made before Closing the Form.

You need to change your

DoCmd.Close

to

If Me.Dirty Then Me.Dirty = False
DoCmd.Close

or

DoCmd.RunCommand acCmdSaveRecord
DoCmd.Close

Linq ;0)>


The Missinglinq

Richmond, Virginia

The Devil's in the Details!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top