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

Disable Close Button

Status
Not open for further replies.

sub5

Programmer
Oct 12, 2005
104
I have successfully been using a slightly modified version of Jazzz's code in this thread.
Need to Disable Close Button
thread702-686356 (see code below)
(I am using Access97)

However, on my form code toggles tabs between visible true/false. Sometimes when I reopen a form it appears to have saved the changes my code made during the previous data inputing operation ie the last tab is visible when I re-open the form instead of the first.

Can anyone tell me if this code is saving the changes my code is making to the control properties when a data inputer is using the form?

Option Compare Database
Option Explicit
Public pblnAllowClose As Boolean

Private Sub cmdExit_Click()
pblnAllowClose = True
DoCmd.Close
End Sub

Private Sub Form_Load()
pblnAllowClose = False
End Sub

Private Sub Form_Unload(Cancel As Integer)
If pblnAllowClose = False Then
MsgBox "You cannot X out of the database, please use the EXIT button", vbOKOnly, "CANNOT X OUT"
Else
Cancel = False
End If
End Sub
 
Yes it is being saved. The full definition of the "Close" method is
Code:
DoCmd.Close ObjectType, ObjectName, Save
If you leave "ObjectType" and "ObjectName" blank then the method closes the current window.

"Save" may have one of 3 values Yes | No | Prompt.
If you don't specify then "Yes" is the default.

BTW: It looks like your form will always close because you are not canceling the UnLoad event when "pblnAllowClose" is false.
 
I thought the default was prompt? here is an extract from the access help:

The Close method carries out the Close action in Visual Basic. For more information on how the action and its arguments work, see the action topic.

Syntax

DoCmd.Close [objecttype, objectname], [save]

The Close method has the following arguments.

Argument Description

objecttype One of the following intrinsic constants:
acDefault (default)
acForm
acMacro
acModule
acQuery
acReport
acTable
objectname A string expression that's the valid name of an object of the type selected by the objecttype argument.
save One of the following intrinsic constants:
acSaveNo
acSavePrompt (default)
acSaveYes
If you leave this argument blank, the default constant (acSavePrompt) is assumed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top