If you simply want a solid colour to fill the whole screen, make a form with that colour Detail and set:
- Scroolbars = Neither
- Record Selectors = No
- Navigation Buttons = No
- Dividing Lines = No
- Auto Resize = No
- Auto Centre = Yes
- Pop up = Yes
- Modal = No
- Border Style = None
If you want a picture, you'll need to make different size forms to fill different resolutions and open the relevant form.
In the form's VBA enter
Expand|Select|Wrap|Line Numbers
- Private Sub Form_Resize()
- Me.Painting = False
- DoCmd.Maximize
- Me.Painting = True
- End Sub
Expand|Select|Wrap|Line Numbers
- With DoCmd
- .Echo False
- .OpenForm <FormName>
- .Echo True
- End With
Expand|Select|Wrap|Line Numbers
- If (CurrentProject.AllForms(<Form Name>).IsLoaded) Then
- DoCmd.Close acForm, <Form Name>
- End If
If you want to make it transparent for a dimming effect for errors or logins etc. add a module:
Expand|Select|Wrap|Line Numbers
- Private Declare Function GetWindowLong Lib "User32" Alias "GetWindowLongA" _
- (ByVal hWnd As Long, _
- ByVal nIndex As Long) As Long
- Private Declare Function SetWindowLong Lib "User32" Alias "SetWindowLongA" _
- (ByVal hWnd As Long, _
- ByVal nIndex As Long, _
- ByVal dwNewLong As Long) As Long
- Private Declare Function SetLayeredWindowAttributes Lib "User32" _
- (ByVal hWnd As Long, _
- ByVal crKey As Long, _
- ByVal bAlpha As Byte, _
- ByVal dwFlags As Long) As Long
- Private Const LWA_ALPHA As Long = &H2
- Private Const GWL_EXSTYLE As Long = -20
- Private Const WS_EX_LAYERED As Long = &H80000
- Public Sub SetFormOpacity(frm As Form, sngOpacity As Single)
- Dim lngStyle As Long
- ' get the current window style, then set transparency
- lngStyle = GetWindowLong(frm.hWnd, GWL_EXSTYLE)
- SetWindowLong frm.hWnd, GWL_EXSTYLE, lngStyle Or WS_EX_LAYERED
- SetLayeredWindowAttributes frm.hWnd, 0, (sngOpacity * 255), LWA_ALPHA
- End Sub
Expand|Select|Wrap|Line Numbers
- Private Sub Form_Resize()
- Me.Painting = False
- DoCmd.Maximize
- SetFormOpacity Me, 0.7
- Me.Painting = True
- End Sub
When combined with several dimming 'stages', forms can effectively fade in and out when opened and closed as well as becoming slightly transparent when they lose focus.
Note: To achieve a smooth fade, you need to remove all the Me.Painting = attributes.
When the forms have no borders, this can create a very nice floating form effect.