Hide Main DB window - only show form - ACCESS 2010 (1 Viewer)

alvarogueva

Registered User.
Local time
Yesterday, 21:18
Joined
Nov 5, 2016
Messages
91
Hi

Just to clarify the 'Breach'.......

I read in MS documentation that it is in breach not to display the runtime text "powered by Microsoft access runtime" and the associated logo.

In one of my apps, I needed to hide the window so read in depth what I could get away with. I placed the text and logo onto my form this still displaying what I should be displaying.

Not only do I hide my window, it's completely hidden from everyone and I placed a systray icon with options :)

Thanks

Nigel

Hey Nigel;

I am a bit confuse of where to place your code. I have other VBA around my database and I don't wan to mess it up. Can you give me the idea of where each of this codes goes in events?

thanks!
 

DBug

Registered User.
Local time
Today, 05:18
Joined
Jan 3, 2017
Messages
24
I have used this code and it hides the Application, but also the PopUp form.

I am using Windows 10 64bit Access 2013

I used the PtrSafe in the Declare Function to make it run on 64 bit

Any ideas?
 

DBug

Registered User.
Local time
Today, 05:18
Joined
Jan 3, 2017
Messages
24
I couldnt run the Database, the code wouldnt compile. So I extracted the module for hiding the App, had the same problem
 

DBug

Registered User.
Local time
Today, 05:18
Joined
Jan 3, 2017
Messages
24
Although I have made my main from popup and sloats around the screen, if I click the minimise button on the application window it also minimizes my form?
 

isladogs

MVP / VIP
Local time
Today, 05:18
Joined
Jan 14, 2017
Messages
18,209
Sorry forgot you were using 64-bit Access - very few people do so.
I've just updated the APIs to work with 64-bit & checked it runs OK here
I used Access 2016 64-bit

New version attached

On the highly unlikely event you still have problems, open holding down the Shift key & check you have no references marked as MISSING due to dropping from 2016 on my PC to 2013 on yours
 

Attachments

  • SetWindows.accdb
    1.9 MB · Views: 270
Last edited:

joe904

New member
Local time
Yesterday, 23:18
Joined
Nov 19, 2017
Messages
5
Hi Nigel,

I tried using the code you supplied, but I keep getting this error:

"The expression On Load you entered as the event property setting produced error: Only comments may appear after End Sub, End Function, or End Property"

I was wondering if you could help me. I apologize I am a NOOB when it comes to VB. I have created a login form that I want to show as a pop-up with no background but the desktop. This is the code I have so far. I feel like it is a simple fix. Any help is much appreciated.



Option Compare Database



Private Sub Form_Load()
DoCmd.ShowToolbar "Ribbon", acToolbarNo
End Sub




Private Sub Command1_Click()
Dim UserLevel As String



If IsNull(Me.txtLoginID) Then
MsgBox "Please enter LoginID", vbInformation, "LoginID Required"
Me.txtLoginID.SetFocus


ElseIf IsNull(Me.txtPassword) Then
MsgBox "Please enter password", vbInformation, "Password Required"
Me.txtPassword.SetFocus


Else
'process the job
If (IsNull(DLookup("[UserLogin]", "tblUser", "[Userlogin] ='" & Me.txtLoginID.Value & "' And password = '" & Me.txtPassword.Value & "'"))) Then
MsgBox "Incorrect LoginID or Password"

Else
UserLevel = DLookup("UserSecurity", "tblUser", "UserLogin = '" & Me.txtLoginID & "'")
DoCmd.Close

If UserLevel = "Admin" Then
MsgBox "ENTRY HAS BEEN APPROVED!!"

DoCmd.OpenForm "Navigation Form"
Else
DoCmd.OpenForm "Student Form"
End If

End If
End If
End Sub


Option Compare Database
Option Explicit

Global Const SW_HIDE = 0
Global Const SW_SHOWNORMAL = 1
Global Const SW_SHOWMINIMIZED = 2
Global Const SW_SHOWMAXIMIZED = 3

Private Declare Function apiShowWindow Lib "user32" _
Alias "ShowWindow" (ByVal hWnd As Long, _
ByVal nCmdShow As Long) As Long

Function fSetAccessWindow(nCmdShow As Long)

Dim loX As Long
Dim loForm As Form
On Error Resume Next
Set loForm = Screen.ActiveForm

If Err <> 0 Then
loX = apiShowWindow(hWndAccessApp, nCmdShow)
Err.Clear
End If

If nCmdShow = SW_SHOWMINIMIZED And loForm.Modal = True Then
MsgBox "Cannot minimize Access with " _
& (loForm.Caption + " ") _
& "form on screen"
ElseIf nCmdShow = SW_HIDE And loForm.PopUp <> True Then
MsgBox "Cannot hide Access with " _
& (loForm.Caption + " ") _
& "form on screen"
Else
loX = apiShowWindow(hWndAccessApp, nCmdShow)
End If
fSetAccessWindow = (loX <> 0)
End Function
 

isladogs

MVP / VIP
Local time
Today, 05:18
Joined
Jan 14, 2017
Messages
18,209
Hi Joe

Welcome to AWF

If you're having trouble with hiding the window, have you tried my version - link in post #46
Its slightly different to what Nigel Shaw posted

Also, a quick scan of your code shows errors in the If ..End If section
There are 2 Else statements as well as an ElseIf
IF you need both then change the first to ElseIf as well

Code:
If ...

ElseIf ...

ElseIf ...

Else

End If

I haven't looked at the full code so its possible there are other errors.

That first section of code goes in your form code module.

The second section of code needs to be moved to a separate 'standard' module.

NOTE
Allways add the line Option Explicit at the top of each module under Option Compare Database
It will ensure all variables are correctly defined in your code
 
Last edited:

joe904

New member
Local time
Yesterday, 23:18
Joined
Nov 19, 2017
Messages
5
Hi Ridders,

Your version is exactly what I am looking for. I tried incorporating your modules
into my Login Form, but it did not work for me. I have included screen shots. I also looked at the Else statements and I was not sure which one did not belong. I got this code from another user. The login form does work. Can you give me some more insight? Any help you can give me is very much appreciated.
 

Attachments

  • pic1.jpg
    pic1.jpg
    79.6 KB · Views: 164
  • pic2.png
    pic2.png
    36.5 KB · Views: 158
  • pic3.jpg
    pic3.jpg
    91.2 KB · Views: 166

isladogs

MVP / VIP
Local time
Today, 05:18
Joined
Jan 14, 2017
Messages
18,209
Can you zip and upload your db.
Remove most of the data leaving a couple of modified records so I can login.
Make sure you tell me a userid & password combination!
 

joe904

New member
Local time
Yesterday, 23:18
Joined
Nov 19, 2017
Messages
5
Here is the zip...

user - ridders
pass - 1234
 

Attachments

  • Student Database.zip
    251.2 KB · Views: 147

isladogs

MVP / VIP
Local time
Today, 05:18
Joined
Jan 14, 2017
Messages
18,209
Thanks. Think I can manage that!
Will have a look and get back to you
 

isladogs

MVP / VIP
Local time
Today, 05:18
Joined
Jan 14, 2017
Messages
18,209
OK - this is what I've done so far.
I've taken a few liberties but you can reverse things you don't like

1. Added missing reference - Microsoft Visual Basic for Applications Extensibility - needed so that it compiles!

2. Added missing line in Form_Load event of the Login Form
Code:
SetAccessWindow (SW_SHOWMINIMIZED)

3. Indented the code on your Command1_Click event so I could check it.
In fact the number of If ...Else... End Ifs are fine but the code isn't very neat.
I'll leave that to you however.

I recommend you name your buttons something meaningful like cmdOK / cmdCancel

4. The Login Form now floats on the desktop as you require.



However, the Access window flashes briefly first
There are ways around that.
The easiest is to open the database with a shortcut and set that to run Minimised. I've included that in the zip file - you'll need to alter the path ...

5. If the user clicks Cancel, the database should close - I've altered the code to do that:
Code:
Application.Quit

6. After clicking OK, I get an irritating message "Entry has been approved".
I suggest you get rid of that and go straight to the next form.
I've disabled it for now

7. When the Navigation form opens, the Access window will appear.
If you don't want that, you'll need to alter the code further

NOTE:
It is a breach of Access runtime conditions to hide the Access window ... or more accurately you should have this wording visible 'Powered by Microsoft Access'
It should be fine to ignore this for a login form but if you intend to hide the Access window completely whilst the db is open, I'd add the phrase in small letters somewhere on the main form used

Finally, clicking on the taskbar icon will cause the Access window to reappear.
Its not possible to prevent this UNLESS you also hide the taskbar icon as well.
That's possible but I really don't recommend it.

For further info on this, see the link in the code repository
https://access-programmers.co.uk/forums/showthread.php?t=293584

OK - over and out ... :)
 

Attachments

  • Capture.jpg
    Capture.jpg
    69.4 KB · Views: 681
  • Student Database-CR.zip
    236.7 KB · Views: 150
Last edited:

NigelShaw

Registered User.
Local time
Today, 05:18
Joined
Jan 11, 2008
Messages
1,573
Hi Nigel,

I tried using the code you supplied, but I keep getting this error:

"The expression On Load you entered as the event property setting produced error: Only comments may appear after End Sub, End Function, or End Property"

I was wondering if you could help me. I apologize I am a NOOB when it comes to VB. I have created a login form that I want to show as a pop-up with no background but the desktop. This is the code I have so far. I feel like it is a simple fix. Any help is much appreciated.

Hi

Been a while since I have been on this forum, I moved to vb.net.

If the code you posted is the code you are using, then this maybe your issue. You can only have this at the top of a module

Option Compare Database
Option Explicit

Nige
 

isladogs

MVP / VIP
Local time
Today, 05:18
Joined
Jan 14, 2017
Messages
18,209
Hi Nigel

You won't know me as I only joined in Feb of this year after lurking as a guest since around 2001.

I've seen some of your old posts but noticed you had been missing for a while.
Yesterday Bob Larson reappeared after 4 years or so ...
Something's in the air :)

Anyway, just to say I posted a similar solution a few months back to the code repository.
I hadn't seen yours at the time.
Your code looks similar to that on Phil Stiefel's website at www.codekabinett.com
Is it the same source?
 

joe904

New member
Local time
Yesterday, 23:18
Joined
Nov 19, 2017
Messages
5
@ Ridders
I really appreciate the help Ridders... I tried the .zip file you attached, but it is still doing the same thing. Is it this the correct file?
 

isladogs

MVP / VIP
Local time
Today, 05:18
Joined
Jan 14, 2017
Messages
18,209
Doh!
I re-posted your original database by mistake! ¬:eek:

Hopefully correct this time & I'll also modify the attachment in the last post
 

Attachments

  • Student Database-CR.zip
    236.7 KB · Views: 169

joe904

New member
Local time
Yesterday, 23:18
Joined
Nov 19, 2017
Messages
5
@Ridders Thanks again for the help. It works really good. I actually added the ENTRY MESSAGE but it is ok, that you disabled it. How do I enable again if decide later on to activate it again? I erased the "CR - disabled" code after the message but it continued not to show when I entered the correct user and password.
 

isladogs

MVP / VIP
Local time
Today, 05:18
Joined
Jan 14, 2017
Messages
18,209
Remove the single quote ' at the start of the line
 

NigelShaw

Registered User.
Local time
Today, 05:18
Joined
Jan 11, 2008
Messages
1,573
Your code looks similar to that on Phil Stiefel's website at www.codekabinett.com
Is it the same source?

Hi

No i havent seen that site before. Mine was a bit of a frankensteins monster if im honest. I have written some code then found some code that nearly did what i wanted so i merged them together and got my result. Mine includes a minimize to the systray which is where it originally came from.

I want to upload my full original splashbuilder tool that i wrote the code for into the repository but at 13mb, im not allowed. Any suggestions?. The tool uses the methods but also allows you to create a splash screen and add it to your existing database. it will set up everything and create a shortcut on the desktop. Run the shortcut and your app will open without the Access Window. See video for reference.

I had intended to make this a tool to sell but with work commitments etc etc, i fell by the wayside and eventually got shelved.

I hope you can get some use out of it, there are some good code examples in there for various things, I only ask that you credit me with any of my code used. :)


Best

Nigel
 

Users who are viewing this thread

Top Bottom