How to pass a Company ID thorughout all forms

dazadd99

Registered User.
Local time
Today, 18:41
Joined
Mar 21, 2005
Messages
19
Hi,

I have a database that controls donations for a Charity. There is to be a sister charity added to the database and a lot of the previously created objects can be used to provide for the new Charity.
My idea was to create a "company" ID and label the categories of the donations. I could then use this company ID to identify to whom the data captured belongs.

I have used the switchboard manager to enable navigation, in this I have a ONload event procedure that requests the Company ID (1 or 2).
That's as far as I have got.

How would I get Switchboard to open each form (some being based on queries - a couple direct on the tables) and filter the data on the company ID?

If there is a better way, please enlighten me!! :)

Many thanks in advance

daz.
 
I was heading down the road of global variables.
I had created a public variable something like "company=Inputmsg("Company 1 or 2"). Put this in the OnLoad event. This works with the main switchboard form, but fails when i try to refer to it for opening the next form with the filter based on "company".

How does my approach sound? Worth while progressing or shall I get a job driving taxi cabs?? (no offence to cab drivers!)

Thanks

Daz.
 
make sure whatever form you are using to set your first vaiable stays open. For example if you have a main menu which is where the select their compnay then it needs to stay open so you can reffer to the variable. Then simply set the criteria in the query.
 
Slight change of plan

After further investigation, it appears that the two charities are more disimilar than I thought. Most of the tables/queries/forms and reports have had to be tweaked to comply with the new charity's business practices.
Hence I have created copies of all major structures.

I have altered the switchboard to route users down the 2 different paths of the charities, but my boss requires restrictions from workers looking at the others data. (I think it infringes on Data protection issues).

I have also applied the LoggingOn sample database to this to generate users and userlevels. (nice bit of work btw).

On switchboard Items tables I have added a field that holds a SetupID for each switchboard item/command.

Can the switchboard be made to restrict access to groups based on the user level?

I have tried this below, the prompt works, but still navigates to the next sub-level. Any ideas how I prevent this or at least return to the main page?

Select Case rs![Command]
' Go to another switchboard.
Case conCmdGotoSwitchboard
Me.Filter = "[ItemNumber] = 0 AND [SwitchboardID]=" & rs![Argument]
' Open a form in Add mode.
Case conCmdOpenFormAdd
DoCmd.OpenForm rs![Argument], , , , acAdd

' Open a form.
Case conCmdOpenFormBrowse
DoCmd.OpenForm rs![Argument]

' Open a report.
Case conCmdOpenReport
DoCmd.OpenReport rs![Argument], acPreview

' Customize the Switchboard.
Case conCmdCustomizeSwitchboard
' Handle the case where the Switchboard Manager
' is not installed (e.g. Minimal Install).
On Error Resume Next
Application.Run "ACWZMAIN.sbm_Entry"
If (Err <> 0) Then MsgBox "Command not available."
On Error GoTo 0
' Update the form.
Me.Filter = "[ItemNumber] = 0 AND [Argument] = 'Default' "
Me.Caption = Nz(Me![ItemText], "")
FillOptions

' Exit the application.
Case conCmdExitApplication
CloseCurrentDatabase

' Run a macro.
Case conCmdRunMacro
DoCmd.RunMacro rs![Argument]

' Run code.
Case conCmdRunCode
Application.Run rs![Argument]

' Open a Data Access Page
Case conCmdOpenPage
DoCmd.OpenDataAccessPage rs![Argument]

' Any other command is unrecognized.
Case Else
MsgBox "Unknown option."
End Select

If User.UserLevel = 4 And SetupID = 1 Then
MsgBox "Not Authorised", vbOKOnly, "Authorisation Required"
Else: End If

Many thanks for help already,
Regards

Daz
 
Think I have something that works for me

Select Case rs![Command]
' Go to another switchboard.
Case conCmdGotoSwitchboard
If User.UserLevel = 4 And SetupID = 1 Then
MsgBox "Not Authorised", vbOKOnly, "Authorisation Required"
Me.Filter = "[SwitchboardID]=5 AND [Itemnumber]=0"
Else:
Me.Filter = "[ItemNumber] = 0 AND [SwitchboardID]=" & rs![Argument]
End If


The code in Red reurns the user to the Main page of the switchboard if they are not authorised to access it.
Probably not the best way around but it does the job!!

regards

Daz.
 

Users who are viewing this thread

Back
Top Bottom