Select Case Function and Bound Fields?

Maxi2011

Registered User.
Local time
Today, 03:30
Joined
Aug 6, 2004
Messages
16
Hi

I am using a Select Case function change what different user levels can do on some forms where if they are case one, they can access a field on the form called [contractslink] as normal but in case two this field is disabled. [Contractlink] is a textbox field which is bound to a hyperlink field in my tables which the user can click on to open a PDF file.


Unfortunately the code doesn't seem to be working. It compiles Ok but when I try it out it doesn't enabled/disable the field as it should. The code I am using is:

Private Sub Form_Open(Cancel As Integer)
On Error Resume Next

Select Case UserName.UserPermission

Case 1
Me.ContractLink.Enabled = True
Me.AllowAdditions = True
Me.AllowDeletions = True
Me.AllowEdits = True


Case 2
Me.ContractLink.Enabled = False
Me.AllowAdditions = True
Me.AllowDeletions = False
Me.AllowEdits = True

End Select
End Sub

I have also tried using this for the On-Load property. Is this something to do with the field type I am trying to change the property for? I have changed the field name, so I am sure that it's not a case of the table and field names being the same and confusing Access and I can't see a problem with my code........but then again I am still learning VBA so there probably is somerwhere!

Any help would be apprciated. Thanks!
 
Start with the simple thing. Place a Msxbox under each case to ensure it is being called correctly.. ie:

Select Case UserName.UserPermission

Case 1
MsgBox "Case 1"
Me.ContractLink.Enabled = True
Me.AllowAdditions = True
Me.AllowDeletions = True
Me.AllowEdits = True


Case 2
Msgbox "Case 2"
Me.ContractLink.Enabled = False
Me.AllowAdditions = True
Me.AllowDeletions = False
Me.AllowEdits = True

End Select
End Sub

If that is OK place a couple of buttons on the form to enable and disable the field.

Dave
 
Avoiding More Passwords

Hi

Thanks for the reply. I have actually got something set up at the moment using a command button but I really want to avoid having more passwords when I don't need them.

Oldsoftboss said:
You ned to add the Select Case to EVERY form you create. Sounds like a lot of work, but you only have to do it once (Copy & Paste are wonderful things!)Dave

That quote is from the sample database section where PaulReed uploaded his customised database security system. I'm using using the system (with some amendments) which is what i am trying to apply the above code to.

I assume since we've got the cases set up already and just need to refer back to them for each form, that I should be able to do this without the enable/disable button but it just doesn't seem to be working on this particular field.

Is there something which could be causing this? I doubt it has anything to do with any of the amendments I have made since the Any suggestions on how I can get it working?

Thanks Again

Maxi
 
I ment you should put a couple of buttons on the form purely for testing. Once you are able to achive the desired result / effect, update the code and delete the buttons. Sorry for the confusion.

Dave
 
No luck......

Hi

No luck with the test buttons I'm afraid. It's literally like there's no code attached to the button - I click it - nothing happens. I am pretty sure that it must be a problem with setting the SELECT CASE function up to begin with. Any ideas what the problem could be?

Is there another way to reference what you want the variable to be for the case? Or some alternative I could try here? I'm really at a loss on what else to try now....

Thanks
Maxi
 
you could try adding an else statment to double check the value pased

Case 1
MsgBox "Case 1"
Me.ContractLink.Enabled = True
Me.AllowAdditions = True
Me.AllowDeletions = True
Me.AllowEdits = True


Case 2
MsgBox "Case 2"
Me.ContractLink.Enabled = False
Me.AllowAdditions = True
Me.AllowDeletions = False
Me.AllowEdits = True
Case Else
MsgBox "Value passed" & UserName.UserPermission
End Select


Peter
 
Solved!

Thanks for the help guys.

Managed to solve it! I was referencing my SELECT CASE function incorrectly and it was picking up data from another table by the look of it!

Thanks again!
Maxi
 
i was hoping to find this sample database by PaulReed that is referenced. it looks to be exactly what im struggling to write myself, is this one of those 'presitehack' references i keep encountering? i'll keep looking for my own explanation..
 
i believe thats what im looking for, wonder why i couldnt find it.

THANKS!
 

Users who are viewing this thread

Back
Top Bottom