Edit button for records made by that user (1 Viewer)

Megaduck

Member
Local time
Today, 17:36
Joined
Apr 24, 2020
Messages
30
Currently, this is what I have setup:
Code:
Dim UserLevel As String

UserLevel = Nz(DLookup("[Role]", "[Employee List]", "[Employee Name]='" & [TempVars]![CurrentUserID] & "'"), 0)

If UserLevel = "Admin" Then
    Me.AdminEdit.Visible = True
Else
    Me.AdminEdit.Visible = False
    
End If

Edit button only appears next to records if that person is Admin.

However, what I want to do is display the same button next to records tied to that user. So, in theory, if the user makes a mistakes and needs to adjust something they can, but they can't edit someone else's records.

Making the button work for a given user is no problem, but I don't want it displayed beside all records. Only those where that person name is in the record.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 14:36
Joined
Oct 29, 2018
Messages
21,358
Hi. This is easy to do with a single view form but a little harder with a continuous view form. Which one are you using?
 

Megaduck

Member
Local time
Today, 17:36
Joined
Apr 24, 2020
Messages
30
Hi. This is easy to do with a single view form but a little harder with a continuous view form. Which one are you using?
I'm using a continuous form. That's what was confusing me; if I just place a button, it will display for all.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 14:36
Joined
Oct 29, 2018
Messages
21,358
I'm using a continuous form. That's what was confusing me; if I just place a button, it will display for all.
Exactly! That's the standard behavior with continuous forms. So, using a continuous form will take some work. I think, recently, I've seen someone show you can use the Format(?) event.
 

cheekybuddha

AWF VIP
Local time
Today, 21:36
Joined
Jul 21, 2014
Messages
2,237
Hi,

You can toggle the Enabled property of a button using Conditional Formatting (I *think*)
 

Cronk

Registered User.
Local time
Tomorrow, 08:36
Joined
Jul 4, 2013
Messages
2,770
Yes, you can definitely toggle the Enabled property of a button using Conditional Formatting by having using the condition that the user logged on is either the Admin or the user who created the record.

Alternatively, make the button so anyone can use it, then check permissions in the OnClick event.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 14:36
Joined
Oct 29, 2018
Messages
21,358
Yes, you can definitely toggle the Enabled property of a button using Conditional Formatting by having using the condition that the user logged on is either the Admin or the user who created the record.
I didn't know this was possible, or more like I didn't know how. Do you have a demo?
 

cheekybuddha

AWF VIP
Local time
Today, 21:36
Joined
Jul 21, 2014
Messages
2,237
Actually, you can't use CF on a button - grrr!

You can spoof it with a textbox. 😬
 

Attachments

  • Database1.accdb
    340 KB · Views: 114

June7

AWF VIP
Local time
Today, 13:36
Joined
Mar 9, 2014
Messages
5,423
CF only for textboxes and comboboxes. But can set up a textbox to look like a button and use its Click event. Apply CF to that textbox. Oh, now I see cheekybuddha has provided example.
 

Megaduck

Member
Local time
Today, 17:36
Joined
Apr 24, 2020
Messages
30
Alternatively, make the button so anyone can use it, then check permissions in the OnClick event.
This is what I was thinking of doing, if nothing else. Can just have a Msgbox message if permissions aren't valid.
 

Users who are viewing this thread

Top Bottom