Storing Control properties in a table (1 Viewer)

mjdemaris

Working on it...
Local time
Today, 13:10
Joined
Jul 9, 2015
Messages
424
Hi all.

I am using one form to create new records as well as view existing records for review/editing.

I have all the controls disabled by default, and only enabled based on New Record, who is viewing the existing record, what the status of the record is and what department the users are in.

What I am trying to do is loop through each control to enable them based on these various criteria.

I have tried using multiple tags, such as 1, 2, 3, 4 so that I can loop through looking for a value of 1 or 2, etc., but if there are multiple tags, the control is skipped in the loop.

Then, I found this page: http://http://www.pcreview.co.uk/threads/assigning-more-than-one-tag-to-tag-property.3150550/
in which one user suggests using a table to store control property data, but does not say exactly how.

Suggestions on how to get this to work?

Thanks,
Mike
 

Cronk

Registered User.
Local time
Tomorrow, 07:10
Joined
Jul 4, 2013
Messages
2,770
For those controls to be enabled, you could store the control name against the UserID, and not bother with tags.

Incidentally, you might be better putting users into groups rather than setting individual user permissions. I have used ViewOnly, EditData, Admin. You could have DeptAEdit, DeptAViewOnly, DeptANoAccess etc
 

missinglinq

AWF VIP
Local time
Today, 16:10
Joined
Jun 20, 2003
Messages
6,423
To use multiple Tags, like this, you can use something like this, in an appropriate event:

Code:
Dim ctl As Control

For Each ctl In Me.Controls
  
 If InStr(ctl.Tag, "1") > 0 Then
   'Place code here formatting if Tag is 1
 End If
    
 If InStr(ctl.Tag, "2") > 0 Then
   'Place code here formatting if Tag is 2
 End If

Next ctl
Linq ;0)>
 

mjdemaris

Working on it...
Local time
Today, 13:10
Joined
Jul 9, 2015
Messages
424
@Cronk:
Incidentally, I do have the users in groups (levels). But there remain situations where a low level user may or may not be able to edit the Order data - determined if that user is the creator of the order, and if the order has already been approved or ordered.

Also, the higher level users may edit some information if needed. However, all but one user must operate within their department. That one user oversees four departments.

@linq:
Are you the "Missing Link" in the flesh? Does that mean our 'scientific' search of humanities development can come to an end? Or do we continue the struggle of creating skeletons out of partials and filling in the gaps with our imagination?

While in college, I read about this 'scientist' who said: I cannot accept the fact of Creation, because I cannot believe there is a God. ergo: Evolution is the truth, though we are missing solid evidence that leaves us without a doubt.

No offense intended to anyone, linq's name just sparked a small flame for debate...
 
Last edited:

mjdemaris

Working on it...
Local time
Today, 13:10
Joined
Jul 9, 2015
Messages
424
@Cronk:
What do you mean by 'storing the control name against the UserID'?
 

mjdemaris

Working on it...
Local time
Today, 13:10
Joined
Jul 9, 2015
Messages
424
Well, I used a table to store the controls' name, and additional fields (y/n) to store whether that control should be enabled based on another variable.

So now i can log in as any user and click on the Edit button and only those controls are enabled.
 

Users who are viewing this thread

Top Bottom