By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,428 Members | 1,126 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,428 IT Pros & Developers. It's quick & easy.

Customise datasheet column visibility for different users - Problem with Case and Like

P: n/a
Kev
Hello Everyone,
I am attempting to customise subform datasheet columns for different
users by making them visible or not depending on which ward they are
in.
I am using the tag property on the controls, eg enter GW in the tag of
each column which staff from GW need to see.
However some controls need to be viewed by staff in more than one
ward. So I might need GW 1N to be placed in the tag property. I have
tried Case ctl.tag Like "*GW*" but it does not work.
does anyone have a suggestion of how I can rectify this or a better
way of achieving my goal?

Regards
Kevin

Private Sub DoctorsHandoverSheetSubform_Enter()
Dim ctl As Control
Dim frm As Form_DoctorsHandoverSheetSubform
If FieldChooserSwitch = 0 Then
Select Case Ward
Case "GW"
For Each ctl In DoctorsHandoverSheetSubform
Select Case ctl.Tag
Case ""
GoTo groh
Case ctl.tag Like "*GW*"
ctl.ColumnHidden = False

End Select
groh:
Next
Case "1E"
etc etc
End Select
FieldChooserSwitch = 1
Else
End If
End Sub

May 30 '07 #1
Share this Question
Share on Google+
4 Replies

P: n/a
Kev wrote:
Hello Everyone,
I am attempting to customise subform datasheet columns for different
users by making them visible or not depending on which ward they are
in.
I am using the tag property on the controls, eg enter GW in the tag of
each column which staff from GW need to see.
However some controls need to be viewed by staff in more than one
ward. So I might need GW 1N to be placed in the tag property. I have
tried Case ctl.tag Like "*GW*" but it does not work.
does anyone have a suggestion of how I can rectify this or a better
way of achieving my goal?

Regards
Kevin
Maybe use Instr instead.
For Each ctl In DoctorsHandoverSheetSubform
ctl.ColumnHidden = (Instr(ctl.tag,Ward) 0)
Next
May 30 '07 #2

P: n/a
Kev
Maybe use Instr instead.
For Each ctl In DoctorsHandoverSheetSubform
ctl.ColumnHidden = (Instr(ctl.tag,Ward) 0)
Next
Thanks for the reply Salad
It works on the first iteration but then gives me this error:

Object doesn't support this property or method (Error 438)

I'm not sure what this means.
Regards
Kevin

Jun 1 '07 #3

P: n/a
Kev wrote:
>>Maybe use Instr instead.
For Each ctl In DoctorsHandoverSheetSubform
ctl.ColumnHidden = (Instr(ctl.tag,Ward) 0)
Next


Thanks for the reply Salad
It works on the first iteration but then gives me this error:

Object doesn't support this property or method (Error 438)

I'm not sure what this means.
Regards
Kevin
That's odd. It would appear that one of your controls doesn't have a
Tag property. What I might do, for testing, is in the line just above
ctl.ColumnHidden = (Instr(ctl.tag,Ward) 0)
enter
msgbox ctl.Name
or
debug.print ctl.name

Or maybe enter before the For statment
Dim strCompare As String
strCompare = Me.Ward

And then again I don't know where you are calling this. Here's the For
line I use in one of my form's code modules
For Each ctl In Me.Controls

Since you've assigned the subform to variable frm, perhaps you can use
For Each ctl In frm.Controls
Jun 1 '07 #4

P: n/a
salad wrote:
Kev wrote:
>>Maybe use Instr instead.
For Each ctl In DoctorsHandoverSheetSubform
ctl.ColumnHidden = (Instr(ctl.tag,Ward) 0)
Next

Thanks for the reply Salad
It works on the first iteration but then gives me this error:

Object doesn't support this property or method (Error 438)

I'm not sure what this means.
Regards
Kevin
That's odd. It would appear that one of your controls doesn't have a
Tag property. What I might do, for testing, is in the line just above
ctl.ColumnHidden = (Instr(ctl.tag,Ward) 0)
enter
msgbox ctl.Name
or
debug.print ctl.name

Or maybe enter before the For statment
Dim strCompare As String
strCompare = Me.Ward
Then
ctl.ColumnHidden = (Instr(ctl.tag,strCompare) 0)
>
And then again I don't know where you are calling this. Here's the For
line I use in one of my form's code modules
For Each ctl In Me.Controls

Since you've assigned the subform to variable frm, perhaps you can use
For Each ctl In frm.Controls
Jun 1 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.