|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
(VBA) API calls - disable close report
hi all, sorry if this is a repost, but didn't find anything in searches.
in Access 2000 I have some reports for which I want the close button to be disabled. If it were as easy as a form I could just set the property, but reports don't have that property. Here's what i have so far: Code:
Option Compare Database
Option Explicit
Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, _
ByVal bRevert As Long) As Long
Private Declare Function EnableMenuItem Lib "user32" (ByVal hMenu As _
Long, ByVal wIDEnableItem As Long, ByVal wEnable As Long) As Long
Private Declare Function GetMenuItemInfo Lib "user32" Alias _
"GetMenuItemInfoA" (ByVal hMenu As Long, ByVal un As Long, ByVal b As _
Long, lpMenuItemInfo As MENUITEMINFO) As Long
Private Type MENUITEMINFO
cbSize As Long
fMask As Long
fType As Long
fState As Long
wID As Long
hSubMenu As Long
hbmpChecked As Long
hbmpUnchecked As Long
dwItemData As Long
dwTypeData As String
cch As Long
End Type
Const MF_GRAYED = &H1&
Const MF_BYCOMMAND = &H0&
Const SC_CLOSE = &HF060&
Public Property Get Enabled() As Boolean
Dim hWnd As Long
Dim hMenu As Long
Dim result As Long
Dim MI As MENUITEMINFO
MI.cbSize = Len(MI)
MI.dwTypeData = String(80, 0)
MI.cch = Len(MI.dwTypeData)
MI.fMask = MF_GRAYED
MI.wID = SC_CLOSE
hWnd = Application.Reports("rptCommissionsEdit").hWnd
hMenu = GetSystemMenu(hWnd, 0)
result = GetMenuItemInfo(hMenu, MI.wID, 0, MI)
Enabled = (MI.fState And MF_GRAYED) = 0
End Property
Public Property Let Enabled(boolClose As Boolean)
Dim hWnd As Long
Dim wFlags As Long
Dim hMenu As Long
Dim result As Long
hWnd = Application.Reports("rptCommissionsEdit").hWnd
hMenu = GetSystemMenu(hWnd, 0)
If Not boolClose Then
wFlags = MF_BYCOMMAND Or MF_GRAYED
Else
wFlags = MF_BYCOMMAND And Not MF_GRAYED
End If
result = EnableMenuItem(hMenu, SC_CLOSE, wFlags)
End Property
This is working as long as my report is not maximized. I think maybe the parts that are bold may have something to do with it, but I'm not sure. Once the report is maximized, the close button becomes enabled again. How can I make it so the close button is not enabled when the report is maximized? thank you for any help you can give me. I'm frustrated. |
|
#2
|
|||
|
|||
|
Access report
Strange my Access Report does give you the option to set that the close button should not be shown.
|
|
#3
|
|||
|
|||
|
Quote:
what version of Access? I'm using 2000 and the option is not there |
|
#4
|
|||
|
|||
|
What exactly are you trying to accomplish, maybe there is a another way to do what you are after.
S-
__________________
If you have found a particular post helpful, show your appreciation by adding reputation points to that user by clicking the "scales" image in the upper right had corner of their post. |
|
#5
|
|||
|
|||
|
The main thing I want to do is control what happens when a user wants to close a report.
I have some reports that are basically an edit view: showing the user which records are going to be updated. When the user closes the report, I want him to be able to: 1- change is mind and keep the report open 2- close and allow updates to the records 3- close but do not update the records |
|
#6
|
|||
|
|||
|
Assuming you are use a seperate unbound form (or bound form to a temp table) where the user actually makes the editing changes and the report shows records that he has changed for the purpose of previewing the changes.
I would use the OnClose event of the report to do what you are after, in conjuction with either another form (give you the ability for multiple options), or the inputbox function. S- |
|
#7
|
|||
|
|||
|
yeah, that's how I was handling it before I decided I should eliminate the close button. If it were possible to cancel the close event, that would be great, but since that's not possible, I just didn't like the options.
|
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > (VBA) API calls - disable close report |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|