473,379 Members | 1,190 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Update Forms Module Logic Error?

Brilstern
208 100+
I have developed a login module and one of the functions of it is to iterate through all forms changing the Forms(obj.Name).ShortcutMenu property to true or false depending on the access level.

This works well for the latter half of the process which is locking them all down, but for some reason I have a logic error in setting the property value to true. Thoughts?

I have already tried debugging inside of the For loop and it iterates through each form in the Admin/Design Case, it just doesn't seem to change the property value to true...

Expand|Select|Wrap|Line Numbers
  1. Public Function UpdateForms()
  2.  
  3.     'On Error Resume Next
  4.     Dim obj As AccessObject, dbs As Object
  5.     Set dbs = Application.CurrentProject
  6.  
  7.     Select Case strGlobalAccess
  8.  
  9.         Case "Administrator", "Design"
  10.  
  11.             'Search for open AccessObject objects in AllForms collection.
  12.             For Each obj In dbs.AllForms
  13.  
  14.                 If obj.Name <> "frmBackground" Then
  15.  
  16.                     DoCmd.OpenForm obj.Name, acDesign, , , , acHidden
  17.                     Forms(obj.Name).ShortcutMenu = True
  18.                     DoCmd.Close acForm, obj.Name, acSaveYes
  19.  
  20.                 End If
  21.  
  22.             Next obj
  23.             DoCmd.OpenForm strHomePage
  24.             Exit Function
  25.  
  26.         Case Else
  27.             'Search for open AccessObject objects in AllForms collection.
  28.             For Each obj In dbs.AllForms
  29.  
  30.                 If obj.Name <> "frmBackground" Then
  31.                     DoCmd.OpenForm obj.Name, acDesign, , , , acHidden
  32.                     Forms(obj.Name).ShortcutMenu = False
  33.                     DoCmd.Close acForm, obj.Name, acSaveYes
  34.                 End If
  35.  
  36.             Next obj
  37.             Exit Function
  38.  
  39.         End Select
  40.  
  41. End Function
Mar 3 '17 #1
4 898
PhilOfWalton
1,430 Expert 1GB
This bit of code might put you on the right track

Expand|Select|Wrap|Line Numbers
  1.  
  2. Public Function UpdateForms()
  3.  
  4.     'On Error Resume Next
  5.     Dim FrmName As String
  6.     Dim Frm As Form
  7.     Dim i As Integer
  8.  
  9.     For i = 0 To CurrentProject.AllForms.Count - 1
  10.         FrmName = CurrentProject.AllForms(i).Name
  11.         If FrmName = "Address" Then                ' Named form found
  12.             DoCmd.OpenForm FrmName, acDesign, , , , acHidden
  13.             Set Frm = Forms(FrmName)
  14.             Frm.ShortcutMenu = True
  15.             DoCmd.Close acForm, FrmName, acSaveYes
  16.             Set Frm = Nothing
  17.         End If
  18.     Next i
  19.  
  20. End Function
  21.  
Obviously this is designed just to change my Address form. You would need to change it to <> frmBackground

Phil
Mar 3 '17 #2
Brilstern
208 100+
Thanks for the reply Phil! Checking it now. Any thoughts on why my approach is not working?
Mar 3 '17 #3
Brilstern
208 100+
Ok so I implemented your solution and to no avail... same result. It iterates through the code and runs it, but it still doesn't allow me to use the Shortcut Menu. Quite weird.

Expand|Select|Wrap|Line Numbers
  1. Public Function UpdateForms()
  2.  
  3.     'On Error Resume Next
  4.     Dim FrmName As String
  5.     Dim Frm As Form
  6.     Dim i As Integer
  7.  
  8.     Select Case strGlobalAccess
  9.  
  10.         Case "Administrator", "Design"
  11.  
  12.             'Search for open AccessObject objects in AllForms collection.
  13.             For i = 0 To CurrentProject.AllForms.Count - 1
  14.  
  15.                 FrmName = CurrentProject.AllForms(i).Name
  16.                 If FrmName <> "frmBackground" Then
  17.                     DoCmd.OpenForm FrmName, acDesign, , , , acHidden
  18.                     Set Frm = Forms(FrmName)
  19.                     Frm.ShortcutMenu = True
  20.                     DoCmd.Close acForm, FrmName, acSaveYes
  21.                     Set Frm = Nothing
  22.  
  23.                 End If
  24.  
  25.             Next i
  26.             DoCmd.OpenForm strHomePage
  27.             Exit Function
  28.  
  29.         Case Else
  30.  
  31.             'Search for open AccessObject objects in AllForms collection.
  32.             For i = 0 To CurrentProject.AllForms.Count - 1
  33.  
  34.                 FrmName = CurrentProject.AllForms(i).Name
  35.                 If FrmName <> "frmBackground" Then
  36.  
  37.                     DoCmd.OpenForm FrmName, acDesign, , , , acHidden
  38.                     Set Frm = Forms(FrmName)
  39.                     Frm.ShortcutMenu = False
  40.                     DoCmd.Close acForm, FrmName, acSaveYes
  41.                     Set Frm = Nothing
  42.  
  43.                 End If
  44.  
  45.             Next i
  46.             Exit Function
  47.  
  48.         End Select
  49.  
  50. End Function
Mar 3 '17 #4
PhilOfWalton
1,430 Expert 1GB
Manually change the value of AllowShortcut Menues an d then check if the code is changing the value of AllowShotcut Menus on all the forms to the correct setting.

Phil
Mar 4 '17 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: R Duncan | last post by:
Hi, I'm considering moving a payroll application out of Microsoft Access to some web-based solution. It is getting way to big for Access and the system is growing unstable, so I'm learning PHP...
0
by: pptran | last post by:
Hi, I am trying to rebuild our XS module using the newly installed Perl 5.8.4 with Dynamic Loading and 64-bit Integers enabled. During the XS make process, I ran into the following error...
0
by: Tony Johansson | last post by:
Hello Experts! I reading a book called programming with design pattern revealed by Tomasz Muldner and here I read something that sound strange. "Exception are divided into logic errors and...
8
by: - | last post by:
Hi to All, To reproduce: The expression: object result = flag ? (long) 0 : (double) 0; always evaluated as a double... see dissassembly to ensure the bad compiled code.
3
by: Jeff Brown | last post by:
Does anyone else ever feel like just giving up!!!!! When i edit a record and then update the database i get an error, although i can add a new record completely. The error is : An unhandled...
1
by: mivey4 | last post by:
Okay, The problem is that I have an Access Database that has the following fields: EmpID - Autonumber (PrimaryKey) AccountID - Text IssueReported - Memo DateOpened ...
3
by: David T. Ashley | last post by:
Hi, Red Hat Enterprise Linux 4.X. I'm writing command-line PHP scripts for the first time. I get the messages below. What do they mean? Are these operating system library modules, or...
0
by: brianjadams | last post by:
I would like to be able to customize the ticket used after authenticating a user and customize the authentication call to use a web service. I assume this is possible, but I'm not sure where I...
4
by: Raj | last post by:
Following is a code to print integer equivalent of a hexadecimal number. If the entered number starts with a 0x or a 0X, calculation is done after skipping these two characters. Now, this code...
2
by: sgopavaram | last post by:
Hi, I am using WatiN for web testing and I am using Excel(2007) for data base. and running as VS2008. All code is running fine. But some times I got the error like as "Access is denied....
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.