Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I had posted this same question on 1

Status
Not open for further replies.

bhoran

MIS
Nov 10, 2003
272
US
I had posted this same question on the forms forum but to na avail.

I have 2 user groups (sales, marketing)that generally are kept separate - using user-level security and forms for navigation. They now need visibility of each others reporting.

The forms run in POp-up modal format.

On the OnClose event of the reports I currently have the user sent back to their respective forms i.e. if a sales report is closed it goes to the sales form. However, this will now have to be altered as it can be marketing or sales that have requested the report.

I don't really want to duplicate all the reports just for the OnClose event to return the user tothe right menu.

Is there someway to have a scenario that looks at the group the user is in then opens the correct form? i.e.
If (user is in Sales group) Then
Openform "Sales"
else
if (user is in Marketing group) Then
OpenForm "Marketing"
else
OpenForm "Main"

Any help is greatly appreciated.
 
This may not apply, but...

If you cross boundries, use a Macro. Set the macro to open the forms and what not, and after the forms terminate and go where they think they should, the macro doesn't care, and sets the view back to where it should be. Proably more effective with code though.

ChaZ

Ascii dumb question, get a dumb Ansi
 
I picked up some code from this site and the MS security FAQ and came up with the following:

Dim stDocName As String
Dim stLinkCriteria As String

Dim grp As Group
For Each grp In DBEngine.Workspaces(0).Users(CurrentUser).Groups
Select Case grp.Name
Case "Admins"
stDocName = "Main_Admin"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Case "Marketing"
stDocName = "Main_MKTG"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Case "Sales"
stDocName = "Main_Sales"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End Select
Next grp

This works fine except that an someone from the Admins group could go into the reports from either form and then gets sent to the main_Admin form rather than the form they launched the report from.

Also if someone belongs to 2 groups it launches both forms.

So I guess I need to capture the form that the user launched the report from and then use that to re-open the form when closing the report.
 
I may not be understanding your requirements fully but if you always want to return to the form that called the report, why close the form in the first place? If you don't want it visible you can always hide it and use the Forms collection to unhide it in the OnClose of the report.



Alec Doughty
Doughty Consulting P/L

"Life's a competition. Play hard, but play fair"
 
The main reason for this at the moment is that I am using the form in Modal and pop-up forms so the user has nothing on the screen except this form, no menus nothing.

Therefore I need to close the form before the report can be viewed.

I could drop these attributes but there are other areas where the forms are so large it is necessary and I would like to keep it all standard.

I haven't tried hiding the form that has pop-up and modal turned on. I will have to try it.
 
ok,
If the form must be modal popup then you will not be able to hide the form.

Another option you have is to have a global variable in a module that contains your Form's name. Set this variable right before you launch the report via code.

Then you will be able to launch the correct form by using the Global Variable in your OpenForm line from within the OnClose of the Report.

Alec Doughty
Doughty Consulting P/L

"Life's a competition. Play hard, but play fair"
 
That is what I am after and have trying to do but my coding leaves a fair bit to be desired.

Any help on the actual code to capture the form name would be great thanks.
 
ok,

in a standard module make the following declaration (and place it before any procedures in module)

public frmName as string


now, anywhere you call the report place the following lines before and after your DoCmd.OpenReport as per my example below


....rest of code omitted
frmName = me.name

docmd.openreport etc, etc, etc

docmd.close acForm, frmName
....rest of code omitted




Alec Doughty
Doughty Consulting P/L

"Life's a competition. Play hard, but play fair"
 
That is perfect thanks. I had declared my Public variable in the wrong place (i.e. underneath some other functions instead of above).

Thanks a lot for your help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top