Using one form with different buttons

Wolff

Registered User.
Local time
Today, 09:01
Joined
Nov 26, 2003
Messages
31
Hi all,

I have searched but it has all been fruitless! We have developed a lovely database ;-) which I am now trying to tidy up! Currently we have (for example) a form for users to add new people, and a form for admin's to delete people, make changes to data etc. Essentially these are the same form, one with an extra button (the admin one).

What I am trying to do, is just use one form for this by hiding/displaying the delete button depending on where the form was opened from. Any ideas on the code to use? (Access 2000.... we haven't moved into modern technology yet!) For example, three forms - A, B, C. If I open form C from form A, is shows button A. If I open form C from form B, it doesn't show button A.

Any suggestions welcome :-)

Many Thanks!
 
You can use the "openargs" part of the Docmd.openform to pass along any information you need.

Then in formC do something like
If me.openargs = "Admin" then
me.Delbutton.visible = true
else
me.Delbutton.visible = false
endif

Good luck
 
Simple Software Solutions

Ok

First create a public variable in your start up module Named strFrmCalling

Code:
Public strFrmCalling As String

Secondly on the onclick of the buton on form A that opens the users form enter the following

strFrmCalling = "A"

Finally

On the On Form Load event of the users form ener the following

Code:
If strFrmCalling = "A" Then
      Me.ButtonDelete.Visible = True
Else
      Me.ButtonDelete.Visible = False
End If

Repeat this on the forms that can open the users form and set the flag accordingly. You could also change this to a Boolean flag and respond to that if you wish.


CodeMaster::cool:
 
Superb! Thought it might be something simple!! Added it to one form, working perfectly! Now onto the other 10 forms :-)

Many thanks!
 
Simple Software Solutions

Which option did you go for:confused:
 
sorry - just saw your option on there after posted reply... so Namliam's one at the moment. Just about to try your's DCrake :-)
 
If you have something with user security ... you can use/addapt CDrake's way and addapt it so that you set this global parameter upon login.

This userlevel would then activate/deactivate options all over, using if then else etc...
Besides using Visible, you can also use properties like Enable, locked
Even change form properties like the background color(s) or stuff like that.
 

Users who are viewing this thread

Back
Top Bottom