Trying to implement the SetAccessWindow code (1 Viewer)

psyc0tic1

Access Moron
Local time
Today, 06:58
Joined
Jul 10, 2017
Messages
360
I know I am missing something but I just do not know what
 

isladogs

MVP / VIP
Local time
Today, 11:58
Joined
Jan 14, 2017
Messages
18,186
OK. I can't see anything obvious in the list of differences but thanks for doing that.

If you can upload the two forms and anything else needed to make them work, I'll have a look and see if I can solve it for you.
 

psyc0tic1

Access Moron
Local time
Today, 06:58
Joined
Jul 10, 2017
Messages
360
OK. I can't see anything obvious in the list of differences but thanks for doing that.

If you can upload the two forms and anything else needed to make them work, I'll have a look and see if I can solve it for you.

to be honest I do not know what I can remove and what I cannot. Let me work on making the tables local and strip out the data and I will upload the database.
 

psyc0tic1

Access Moron
Local time
Today, 06:58
Joined
Jul 10, 2017
Messages
360
If you can upload the two forms and anything else needed to make them work, I'll have a look and see if I can solve it for you.

Here it is. Login with user2, user2 for admin.

The forms in question are frm_registrationform and frm_passchange. I have not tried any code on frm_passchange yet as I was trying to get frm_registrationform working first.

Ignore the filename of the db... that was me being a smart-alec to myself
 

Attachments

  • One More Time.zip
    676.4 KB · Views: 33

isladogs

MVP / VIP
Local time
Today, 11:58
Joined
Jan 14, 2017
Messages
18,186
I've spent over 2 hours on this & it was a total PITA to solve.

You had lots of conflicting code which I had to test & undo step by step

I can now open the registration & password change forms without the app window reappearing. The Home form also opens correctly whether or not either of the other 2 forms were opened first.
It all seems to work correctly but you will need to check it carefully

Lots of changes made including:
a) Added Option Compare Database & Option Explicit to EVERY code module
b) Compiled & added a couple of missing definitions to fix errors
c) Changed the 2 problem forms to popup = No. It works with other changes I made
d) Replaced a few embedded macros with event procedures
e) Added a missing reference 'Microsoft Visual Basic for Applications Extensibility'. That is ONLY needed if you use my special error handling code:
Code:
strProc = Application.VBE.ActiveCodePane.CodeModule.ProcOfLine(Application.VBE.ActiveCodePane.TopLine, 0)
f) Disabled form resizing code as you weren't using it

Lots of other things done and were later scrapped as I found better ways of doing things by trial & error

You really need to go through and:
1. rename all controls with meaningful names instead of Command1, Label41 etc. This will make debugging much easier both for you & anyone else
2. remove superfluous code which you've imported but aren't using

NOTE: I've also changed the name! I really don't want / can't afford to spend any more time on this application
 

Attachments

  • One Last Time.zip
    560.9 KB · Views: 30

psyc0tic1

Access Moron
Local time
Today, 06:58
Joined
Jul 10, 2017
Messages
360
I can now open the registration & password change forms without the app window reappearing.

Colin I cannot thank you enough for the time you spent digging through my code.

Maybe there is a difference between Access 2016 (yours) and 2013 (mine) because the registration form and lost password form still opened with the database window maximized behind them. They are both defaulting to acNormal.



However if you click on the forgot password link at the bottom of the registration form you have that set to open acDialog and this is the result


and if you click the cancel button on the lost password from in acDialog, this is the result


I also noticed that while the tables were local, the reports were working fine but once I returned them to linked tables the rep_userlist broke. What is happening is that it no longer likes the filter I had in it to filter out admins and deactivated access levels. This is the filter. This one report now pops up a parameter asking for Lookup_AccessLvl.AccessLvl
Code:
(([Lookup_AccessLvl].[AccessLvl]<>"Admin" Or [Lookup_AccessLvl].[AccessLvl] IS Null)) AND ([Lookup_AccessLvl].[AccessLvl]<>"Deactivated" Or [Lookup_AccessLvl].[AccessLvl] IS Null)
I tried commenting ou the Option Explicit in the frm_newreportcenter where the report is generated from but that didn't change anything.

You really need to go through and:
1. rename all controls with meaningful names instead of Command1, Label41 etc. This will make debugging much easier both for you & anyone else
2. remove superfluous code which you've imported but aren't using

I did as you said and fixed I believe all of the labels, buttons etc. I have been meaning to do that but didn't think it was crucial until after the other things got worked out. I usually save correcting these oversights until everything works.

I couldn't find any superfluous code I wasn't using... there was some code I commented out so it would not try to run while you were testing things. I have since removed the comments and re-activated the code.

All except for these two blocks of code in the frm_registrationform. Since you commented out the calls I was trying (I deleted the commented out calls), aren't these two blocks useless now?
Code:
Private Sub Form_Load()

On Error GoTo Err_Handler
       
Exit_Handler:
    Exit Sub

Err_Handler:
    strProc = Application.VBE.ActiveCodePane.CodeModule.ProcOfLine(Application.VBE.ActiveCodePane.TopLine, 0)
    MsgBox "Error " & Err.Number & " in " & strProc & " procedure : " & Err.Description
    Resume Exit_Handler
    
End Sub

Private Sub Form_Open(Cancel As Integer)

On Error GoTo Err_Handler
        
Exit_Handler:
    Exit Sub

Err_Handler:
    strProc = Application.VBE.ActiveCodePane.CodeModule.ProcOfLine(Application.VBE.ActiveCodePane.TopLine, 0)
    MsgBox "Error " & Err.Number & " in " & strProc & " procedure : " & Err.Description
    Resume Exit_Handler
  
End Sub

I realize you said you did not want to spend any more time on this but I thought I would take a shot since you were now very read up on my code.

If not... no worries, I still cannot thank you enough for all of your effort.
 

Attachments

  • Capture.JPG
    Capture.JPG
    28.9 KB · Views: 146
  • Capture1.JPG
    Capture1.JPG
    26.1 KB · Views: 149
  • Capture2.JPG
    Capture2.JPG
    27.3 KB · Views: 148
  • Capture3.JPG
    Capture3.JPG
    26.7 KB · Views: 147

isladogs

MVP / VIP
Local time
Today, 11:58
Joined
Jan 14, 2017
Messages
18,186
Colin I cannot thank you enough for the time you spent digging through my code
.....

I realize you said you did not want to spend any more time on this but I thought I would take a shot since you were now very read up on my code.

If not... no worries, I still cannot thank you enough for all of your effort.


I did it in A2010 and have just retested what I uploaded
I must have removed more code than I realised as it no longer works!!:confused:
I agree both forms are still defaulting to normal
Aaarrrggghhh! :banghead::banghead:

You can remove both the Form_Open & Form_Load events form the version I uploaded ...though I may have to restore some code later to get it working once more (HOPEFULLY!!!)

Suggest you remove modResizeForm as its not being used.
Also if you replace my specialised error handling code you can delete the extra VBA Extensibility reference again

Please don't remove Option Explicit again - it will only mask underlying issues

I'll try to find time to have yet another last look at the forms later on this evening
Probably not the report though
 

psyc0tic1

Access Moron
Local time
Today, 06:58
Joined
Jul 10, 2017
Messages
360
Please don't remove Option Explicit again - it will only mask underlying issues

Yea... I only tried it to see if it had any effect.

Thank you again so much for your time on this.

I will try to figure out the report issue.
 

isladogs

MVP / VIP
Local time
Today, 11:58
Joined
Jan 14, 2017
Messages
18,186
OK its working again though a slightly different solution this time
Rather than plough through trying to identify what the conflict was I focused on getting it to work reliably

All forms are now opened as acDialog so all show a title bar
Not quite so neat but at least you can move them easily

I've tried various combinations going from login form to registration to password then back to login then opening the home form.
All definitely open with the application window hidden. PHEW!

I've also altered the code in the Register button of the registration form to fix an error if the button clicked with no registration info entered. It no longer closes the form if so

Removed modResizeForm, my 'special' error handling code & VBA Extensibility reference as no longer needed

I didn't look at your report issue
Hopefully, otherwise now OK
 

Attachments

  • One Very Last Time.zip
    659.8 KB · Views: 41

psyc0tic1

Access Moron
Local time
Today, 06:58
Joined
Jul 10, 2017
Messages
360
All forms are now opened as acDialog so all show a title bar
Not quite so neat but at least you can move them easily

I can deal with that... I really liked the no borders part but this accomplishes what I was looking for in the end.

Colin... again... thank you so much for your valuable time spent on this for me.

I've also altered the code in the Register button of the registration form to fix an error if the button clicked with no registration info entered. It no longer closes the form if so

Thank you for catching that.

I didn't look at your report issue
Hopefully, otherwise now OK

Strangely enough that problem went away.

I did however have to switch back from overlapping to tabbed because overlapping caused my subforms on the frm_labtestinput to overlap off the screen. All still works after that.

I also had to switch back these 2 lines
Code:
DoCmd.OpenForm "frm_home", , , , , acDialog 'CR - added acDialog 18/09/2018
DoCmd.Close acForm, Me.Name
and the reason is... once I went back to the linked tables... with this new coding... the frm_home takes like 60 seconds to open now and even I was confused when the login form closed and it took so long for the main form to open... users will be wondering what happened since there was no indication as to what was going on at the time. Switching those lines at least leaves the login form open until the home form opens.

It would however, be nice to know why it takes so long to open now... before through everyone's help, it was opening frm_home is 10 seconds or less.
 

isladogs

MVP / VIP
Local time
Today, 11:58
Joined
Jan 14, 2017
Messages
18,186
You're welcome

As you have a delay of more than a second or so, I would suggest you use the hourglass command so users know something is happening

Use DoCmd.Hourglass True as you open a form then DoCmd.Hourglass False once it has loaded

Do you want to mark this as solved?

Good luck with the rest of your project
 
Last edited:

psyc0tic1

Access Moron
Local time
Today, 06:58
Joined
Jul 10, 2017
Messages
360
You're welcome

As you have a delay of more than a second or so, I would suggest you use the hourglass command so users know something is happening

Use DoCmd.Hourglass True as you open a form then DoCmd.Hourglass False once it has loaded

Do you want to mark this as solved?

Good luck with the rest of your project

Yea the hourglass does not work on mine due tot he access application basically not responding and therefore the hourglass does not appear.

I really don't know what to do.... this thing opens so slow now it is frustrating.

and today... 9 out of 10 times the app window won't minimize anymore. I didn't change anything.

it is like it is getting slower every time I open it up to see if it is working still.
 

isladogs

MVP / VIP
Local time
Today, 11:58
Joined
Jan 14, 2017
Messages
18,186
When I looked at the cut downversion you uploaded the app responded quickly including the various tabs on frmHome.

My workstation is certainly not a powerful PC. 7 years old and only 4GB RAM.

I would expect response to be slower on a split database especially if you are using a network drive for the BE and if your tabs are connected to tables with many records.

However if a form takes more than 2-3 seconds to load (let alone 60s), you clearly have a serious problem either with your application design or your code or your hardware (or all of these).

It may be you have corrupt compile code. I can't remember whether you have already tried decompiling. If not, do so.

Otherwise I think you may be at the stage where you need to start again with a new database and add items one at a time until problems become apparent.

Alternatively perhaps you should pay a professional developer to review your application. Whilst it won't be cheap, nor is your time and you have clearly devoted a lot of time to this project
 

psyc0tic1

Access Moron
Local time
Today, 06:58
Joined
Jul 10, 2017
Messages
360
When I looked at the cut downversion you uploaded the app responded quickly including the various tabs on frmHome.
Yea... when I use the local tables it is lightening fast for me too... it happens when linking tot he backend on a network drive many states away from me (and all other uses as well unless they are in the same state as the backend).

However if a form takes more than 2-3 seconds to load (let alone 60s), you clearly have a serious problem either with your application design or your code or your hardware (or all of these).
and that is where I get frustrated because while the navigation control version of the database was not lightening fast... it was way faster than the tab control version.{/quote]

It may be you have corrupt compile code. I can't remember whether you have already tried decompiling. If not, do so.

Otherwise I think you may be at the stage where you need to start again with a new database and add items one at a time until problems become apparent.
Believe it or not I read somewhere on how to decompile and I did that before I uploaded the version you looked at.

And I may just be experiencing bad slow network the last few days. I did notice that if I try to open the backend by itself it seems to take longer than usual today. Our IT guys can't tell me much about it... not too smart I guess.
 

isladogs

MVP / VIP
Local time
Today, 11:58
Joined
Jan 14, 2017
Messages
18,186
Access is intended for use on a local area network (LAN). It is not intended for use on a wide area network (WAN), will never perform well and increases the risk of corruption.

I'm not a network expert but clearly all isn't well with your system

Consider using a SQL Server BE instead. It won't produce miracles but should be more robust..

I thought you went with MarkK's solution using tabbed forms and remember you saying it was fast at that time. Something must have changed since then.

It won't do any harm to decompile again but remember to recompile subsequently.
 

psyc0tic1

Access Moron
Local time
Today, 06:58
Joined
Jul 10, 2017
Messages
360
I thought you went with MarkK's solution using tabbed forms and remember you saying it was fast at that time. Something must have changed since then.

It seemed to speed up dramatically once I put in your showminimized coding but after the work you did it got slower than before.

However I believe it is related to the network. I outlined in my other post in the Forms forum what I think I discovered.
https://www.access-programmers.co.uk/forums/showthread.php?t=301527

it is still strange how the app window seems to be reluctant to hide anymore... it started before I tried some things to speed it back up.

It is random but like I said... 9 out of 10 times it will not hide. If I click the "Register as New User" or "Forgot Password" links on the login form it will go ahead and hide the app window when I cancel out of either one of them but for some reason when opening the database most times the app window will not hide
 
Last edited:

isladogs

MVP / VIP
Local time
Today, 11:58
Joined
Jan 14, 2017
Messages
18,186
I've no idea why its playing up for you.
Much as I like the result of hiding the application window, that seems unimportant compared to getting the network speed issue resolved.
However as already stated, that's always going to be an issue using an Access BE over a WAN. You would find SQL Server more reliable over a WAN though not necessarily faster.

Do read the article by Albert Kallal that someone gave a link for in your other thread. Although it's old, the information is still relevant.

BTW you could try replacing the 'floating form' with forms that fill the entire screen. No title bar, no ribbon, no nav pane and optionally no taskbar. It can also be very effective. See Fill Entire Screen option in https://www.access-programmers.co.uk/forums/showthread.php?t=293584

Good luck
 
Last edited:

Users who are viewing this thread

Top Bottom