Select Case help

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have EMT form and a subform “Requir†based on a query which is hold 10
check boxes: Application, EMT, Picture, PCR, CE24, CE36, CE48, Fee30, Fee40,
Test , ….. and a text box “ Lasped†that calculate the date deference
=(Date()-[Expiration Date]) as a control source .
what I want to do
1- If the Lasped is >0 and <182then have check boxes: Application, EMT,
Picture,
CE24, Fee30 Visible and other check boxes Invisible
2- If Lasped is >182 and <365 then have check boxes: Application, EMT,
Picture, CE48, Fee40, Test Visible and other check boxes Invisible
3- If Lasped is >365 and <1095 then have check boxes: Application, EMT,
Picture, CE48, Fee40 , Skill Visible and other check boxes Invisible
4- If Lasped is >1095 then have check boxes: Application, EMT, Picture,
Fee30, CorssCopilation Visible and other check boxes Invisible
any help
Thanks
 
Select Case Lasped
Case Is >0, Is <182
For Each ctl In Me.Controls
If ctl.ControlType = acCheckBox Then
If (ctl.Name = “Application†OR ctl.Name = “EMT†OR _
ctl.Name = “Picture†OR ctl.Name = “CE24†OR _
ctl.Name = “Fee30â€) Then ctl.Visible = True
Else
ctl.Visible = False
End If
End If
Next ctl
Case Is >182, Is <365
…similar statements here…
Case Is >365, Is <1095
…similar statements here…
Case Is >1095
…similar statements here…
End Select

This code uses the name property of the control, which makes for a
cumbersome compound OR statement. You could do something more elegant using
the Tag property of each control, which is kind of a "bonus" control Access
provides for programming convenience.

Since there are four cases, you could assign a four-character Tag for each
checkbox control corresponding whether the control should be visible for that
case or not—“V†for Visible, “I†for Invisible—then use the Mid function to
determine the value of the control for that case.

For example, “Application†is visible in all four cases, so assign a string
of “VVVV†to the Tag property. The “CE24†checkbox is only visible in the
first case, so its Tag would be “VIIIâ€

Then your Select Case statement simplifies to:

Dim intCaseNumber As Integer

Select Case Lasped
Case Is >0, Is <182 ‘ Case 1
intCaseNumber = 1
Case Is >182, Is <365 ‘ Case 2
intCaseNumber = 2
Case Is >365, Is <1095 ‘ Case 3
intCaseNumber = 3
Case Is >1095 ‘ Case 4
intCaseNumber = 4
End Select

For Each ctl In Me.Controls
If ctl.ControlType = acCheckBox Then
If Mid(ctl.Tag,intCaseNumber,1) = “V†Then
ctl.Visible = True
Else
ctl.Visible = False
End If
End If
Next ctl

Hope that helps.
Sprinks

amin said:
I have EMT form and a subform “Requir†based on a query which is hold 10
check boxes: Application, EMT, Picture, PCR, CE24, CE36, CE48, Fee30, Fee40,
Test , ….. and a text box “ Lasped†that calculate the date deference
=(Date()-[Expiration Date]) as a control source .
what I want to do
1- If the Lasped is >0 and <182then have check boxes: Application, EMT,
Picture,
CE24, Fee30 Visible and other check boxes Invisible
2- If Lasped is >182 and <365 then have check boxes: Application, EMT,
Picture, CE48, Fee40, Test Visible and other check boxes Invisible
3- If Lasped is >365 and <1095 then have check boxes: Application, EMT,
Picture, CE48, Fee40 , Skill Visible and other check boxes Invisible
4- If Lasped is >1095 then have check boxes: Application, EMT, Picture,
Fee30, CorssCopilation Visible and other check boxes Invisible
any help
Thanks
 
Hi Sprinks
thanks for Help
but tag method dose not work, I taged the check boxes and placed the code on
current event of the form and the Lasped textbox after update
I'll try to use the name property of the control.
thanks

Sprinks said:
Select Case Lasped
Case Is >0, Is <182
For Each ctl In Me.Controls
If ctl.ControlType = acCheckBox Then
If (ctl.Name = “Application†OR ctl.Name = “EMT†OR _
ctl.Name = “Picture†OR ctl.Name = “CE24†OR _
ctl.Name = “Fee30â€) Then ctl.Visible = True
Else
ctl.Visible = False
End If
End If
Next ctl
Case Is >182, Is <365
…similar statements here…
Case Is >365, Is <1095
…similar statements here…
Case Is >1095
…similar statements here…
End Select

This code uses the name property of the control, which makes for a
cumbersome compound OR statement. You could do something more elegant using
the Tag property of each control, which is kind of a "bonus" control Access
provides for programming convenience.

Since there are four cases, you could assign a four-character Tag for each
checkbox control corresponding whether the control should be visible for that
case or not—“V†for Visible, “I†for Invisible—then use the Mid function to
determine the value of the control for that case.

For example, “Application†is visible in all four cases, so assign a string
of “VVVV†to the Tag property. The “CE24†checkbox is only visible in the
first case, so its Tag would be “VIIIâ€

Then your Select Case statement simplifies to:

Dim intCaseNumber As Integer

Select Case Lasped
Case Is >0, Is <182 ‘ Case 1
intCaseNumber = 1
Case Is >182, Is <365 ‘ Case 2
intCaseNumber = 2
Case Is >365, Is <1095 ‘ Case 3
intCaseNumber = 3
Case Is >1095 ‘ Case 4
intCaseNumber = 4
End Select

For Each ctl In Me.Controls
If ctl.ControlType = acCheckBox Then
If Mid(ctl.Tag,intCaseNumber,1) = “V†Then
ctl.Visible = True
Else
ctl.Visible = False
End If
End If
Next ctl

Hope that helps.
Sprinks

amin said:
I have EMT form and a subform “Requir†based on a query which is hold 10
check boxes: Application, EMT, Picture, PCR, CE24, CE36, CE48, Fee30, Fee40,
Test , ….. and a text box “ Lasped†that calculate the date deference
=(Date()-[Expiration Date]) as a control source .
what I want to do
1- If the Lasped is >0 and <182then have check boxes: Application, EMT,
Picture,
CE24, Fee30 Visible and other check boxes Invisible
2- If Lasped is >182 and <365 then have check boxes: Application, EMT,
Picture, CE48, Fee40, Test Visible and other check boxes Invisible
3- If Lasped is >365 and <1095 then have check boxes: Application, EMT,
Picture, CE48, Fee40 , Skill Visible and other check boxes Invisible
4- If Lasped is >1095 then have check boxes: Application, EMT, Picture,
Fee30, CorssCopilation Visible and other check boxes Invisible
any help
Thanks
 
Hi, Amin.

I got the code to work here.

You may have to make 2 minor changes: do NOT include quotation marks in the
Tag values, just type VVII, for example. Also, remove the quotes around the
V in the following statement:

If Mid(ctl.Tag,intCaseNumber,1) = “V†Then

and then type them back in. I typed my response in Word, and it used
different characters than Access does.

amin said:
Hi Sprinks
thanks for Help
but tag method dose not work, I taged the check boxes and placed the code on
current event of the form and the Lasped textbox after update
I'll try to use the name property of the control.
thanks

Sprinks said:
Select Case Lasped
Case Is >0, Is <182
For Each ctl In Me.Controls
If ctl.ControlType = acCheckBox Then
If (ctl.Name = “Application†OR ctl.Name = “EMT†OR _
ctl.Name = “Picture†OR ctl.Name = “CE24†OR _
ctl.Name = “Fee30â€) Then ctl.Visible = True
Else
ctl.Visible = False
End If
End If
Next ctl
Case Is >182, Is <365
…similar statements here…
Case Is >365, Is <1095
…similar statements here…
Case Is >1095
…similar statements here…
End Select

This code uses the name property of the control, which makes for a
cumbersome compound OR statement. You could do something more elegant using
the Tag property of each control, which is kind of a "bonus" control Access
provides for programming convenience.

Since there are four cases, you could assign a four-character Tag for each
checkbox control corresponding whether the control should be visible for that
case or not—“V†for Visible, “I†for Invisible—then use the Mid function to
determine the value of the control for that case.

For example, “Application†is visible in all four cases, so assign a string
of “VVVV†to the Tag property. The “CE24†checkbox is only visible in the
first case, so its Tag would be “VIIIâ€

Then your Select Case statement simplifies to:

Dim intCaseNumber As Integer

Select Case Lasped
Case Is >0, Is <182 ‘ Case 1
intCaseNumber = 1
Case Is >182, Is <365 ‘ Case 2
intCaseNumber = 2
Case Is >365, Is <1095 ‘ Case 3
intCaseNumber = 3
Case Is >1095 ‘ Case 4
intCaseNumber = 4
End Select

For Each ctl In Me.Controls
If ctl.ControlType = acCheckBox Then
If Mid(ctl.Tag,intCaseNumber,1) = “V†Then
ctl.Visible = True
Else
ctl.Visible = False
End If
End If
Next ctl

Hope that helps.
Sprinks

amin said:
I have EMT form and a subform “Requir†based on a query which is hold 10
check boxes: Application, EMT, Picture, PCR, CE24, CE36, CE48, Fee30, Fee40,
Test , ….. and a text box “ Lasped†that calculate the date deference
=(Date()-[Expiration Date]) as a control source .
what I want to do
1- If the Lasped is >0 and <182then have check boxes: Application, EMT,
Picture,
CE24, Fee30 Visible and other check boxes Invisible
2- If Lasped is >182 and <365 then have check boxes: Application, EMT,
Picture, CE48, Fee40, Test Visible and other check boxes Invisible
3- If Lasped is >365 and <1095 then have check boxes: Application, EMT,
Picture, CE48, Fee40 , Skill Visible and other check boxes Invisible
4- If Lasped is >1095 then have check boxes: Application, EMT, Picture,
Fee30, CorssCopilation Visible and other check boxes Invisible
any help
Thanks
 
Hi Sprinks
I guss that I need the date range to read and instead of Or for example
Case Is >182, Is <365 should be
Case Is >182 And Is <365
but this not working either
Thanks

Sprinks said:
Hi, Amin.

I got the code to work here.

You may have to make 2 minor changes: do NOT include quotation marks in the
Tag values, just type VVII, for example. Also, remove the quotes around the
V in the following statement:

If Mid(ctl.Tag,intCaseNumber,1) = “V†Then

and then type them back in. I typed my response in Word, and it used
different characters than Access does.

amin said:
Hi Sprinks
thanks for Help
but tag method dose not work, I taged the check boxes and placed the code on
current event of the form and the Lasped textbox after update
I'll try to use the name property of the control.
thanks

Sprinks said:
Select Case Lasped
Case Is >0, Is <182
For Each ctl In Me.Controls
If ctl.ControlType = acCheckBox Then
If (ctl.Name = “Application†OR ctl.Name = “EMT†OR _
ctl.Name = “Picture†OR ctl.Name = “CE24†OR _
ctl.Name = “Fee30â€) Then ctl.Visible = True
Else
ctl.Visible = False
End If
End If
Next ctl
Case Is >182, Is <365
…similar statements here…
Case Is >365, Is <1095
…similar statements here…
Case Is >1095
…similar statements here…
End Select

This code uses the name property of the control, which makes for a
cumbersome compound OR statement. You could do something more elegant using
the Tag property of each control, which is kind of a "bonus" control Access
provides for programming convenience.

Since there are four cases, you could assign a four-character Tag for each
checkbox control corresponding whether the control should be visible for that
case or not—“V†for Visible, “I†for Invisible—then use the Mid function to
determine the value of the control for that case.

For example, “Application†is visible in all four cases, so assign a string
of “VVVV†to the Tag property. The “CE24†checkbox is only visible in the
first case, so its Tag would be “VIIIâ€

Then your Select Case statement simplifies to:

Dim intCaseNumber As Integer

Select Case Lasped
Case Is >0, Is <182 ‘ Case 1
intCaseNumber = 1
Case Is >182, Is <365 ‘ Case 2
intCaseNumber = 2
Case Is >365, Is <1095 ‘ Case 3
intCaseNumber = 3
Case Is >1095 ‘ Case 4
intCaseNumber = 4
End Select

For Each ctl In Me.Controls
If ctl.ControlType = acCheckBox Then
If Mid(ctl.Tag,intCaseNumber,1) = “V†Then
ctl.Visible = True
Else
ctl.Visible = False
End If
End If
Next ctl

Hope that helps.
Sprinks

:

I have EMT form and a subform “Requir†based on a query which is hold 10
check boxes: Application, EMT, Picture, PCR, CE24, CE36, CE48, Fee30, Fee40,
Test , ….. and a text box “ Lasped†that calculate the date deference
=(Date()-[Expiration Date]) as a control source .
what I want to do
1- If the Lasped is >0 and <182then have check boxes: Application, EMT,
Picture,
CE24, Fee30 Visible and other check boxes Invisible
2- If Lasped is >182 and <365 then have check boxes: Application, EMT,
Picture, CE48, Fee40, Test Visible and other check boxes Invisible
3- If Lasped is >365 and <1095 then have check boxes: Application, EMT,
Picture, CE48, Fee40 , Skill Visible and other check boxes Invisible
4- If Lasped is >1095 then have check boxes: Application, EMT, Picture,
Fee30, CorssCopilation Visible and other check boxes Invisible
any help
Thanks
 
Hi, Amin.

No, the way it's written is the way it should be. How is it not working?
Are you getting an error message? What behavior are you seeing?

Sprinks

amin said:
Hi Sprinks
I guss that I need the date range to read and instead of Or for example
Case Is >182, Is <365 should be
Case Is >182 And Is <365
but this not working either
Thanks

Sprinks said:
Hi, Amin.

I got the code to work here.

You may have to make 2 minor changes: do NOT include quotation marks in the
Tag values, just type VVII, for example. Also, remove the quotes around the
V in the following statement:

If Mid(ctl.Tag,intCaseNumber,1) = “V†Then

and then type them back in. I typed my response in Word, and it used
different characters than Access does.

amin said:
Hi Sprinks
thanks for Help
but tag method dose not work, I taged the check boxes and placed the code on
current event of the form and the Lasped textbox after update
I'll try to use the name property of the control.
thanks

:

Select Case Lasped
Case Is >0, Is <182
For Each ctl In Me.Controls
If ctl.ControlType = acCheckBox Then
If (ctl.Name = “Application†OR ctl.Name = “EMT†OR _
ctl.Name = “Picture†OR ctl.Name = “CE24†OR _
ctl.Name = “Fee30â€) Then ctl.Visible = True
Else
ctl.Visible = False
End If
End If
Next ctl
Case Is >182, Is <365
…similar statements here…
Case Is >365, Is <1095
…similar statements here…
Case Is >1095
…similar statements here…
End Select

This code uses the name property of the control, which makes for a
cumbersome compound OR statement. You could do something more elegant using
the Tag property of each control, which is kind of a "bonus" control Access
provides for programming convenience.

Since there are four cases, you could assign a four-character Tag for each
checkbox control corresponding whether the control should be visible for that
case or not—“V†for Visible, “I†for Invisible—then use the Mid function to
determine the value of the control for that case.

For example, “Application†is visible in all four cases, so assign a string
of “VVVV†to the Tag property. The “CE24†checkbox is only visible in the
first case, so its Tag would be “VIIIâ€

Then your Select Case statement simplifies to:

Dim intCaseNumber As Integer

Select Case Lasped
Case Is >0, Is <182 ‘ Case 1
intCaseNumber = 1
Case Is >182, Is <365 ‘ Case 2
intCaseNumber = 2
Case Is >365, Is <1095 ‘ Case 3
intCaseNumber = 3
Case Is >1095 ‘ Case 4
intCaseNumber = 4
End Select

For Each ctl In Me.Controls
If ctl.ControlType = acCheckBox Then
If Mid(ctl.Tag,intCaseNumber,1) = “V†Then
ctl.Visible = True
Else
ctl.Visible = False
End If
End If
Next ctl

Hope that helps.
Sprinks

:

I have EMT form and a subform “Requir†based on a query which is hold 10
check boxes: Application, EMT, Picture, PCR, CE24, CE36, CE48, Fee30, Fee40,
Test , ….. and a text box “ Lasped†that calculate the date deference
=(Date()-[Expiration Date]) as a control source .
what I want to do
1- If the Lasped is >0 and <182then have check boxes: Application, EMT,
Picture,
CE24, Fee30 Visible and other check boxes Invisible
2- If Lasped is >182 and <365 then have check boxes: Application, EMT,
Picture, CE48, Fee40, Test Visible and other check boxes Invisible
3- If Lasped is >365 and <1095 then have check boxes: Application, EMT,
Picture, CE48, Fee40 , Skill Visible and other check boxes Invisible
4- If Lasped is >1095 then have check boxes: Application, EMT, Picture,
Fee30, CorssCopilation Visible and other check boxes Invisible
any help
Thanks
 
What I'm seeing is that I'm getting the same result for date range of
Case Is >182, Is <365 with the date range of Case Is >365, Is <1095




Sprinks said:
Hi, Amin.

No, the way it's written is the way it should be. How is it not working?
Are you getting an error message? What behavior are you seeing?

Sprinks

amin said:
Hi Sprinks
I guss that I need the date range to read and instead of Or for example
Case Is >182, Is <365 should be
Case Is >182 And Is <365
but this not working either
Thanks

Sprinks said:
Hi, Amin.

I got the code to work here.

You may have to make 2 minor changes: do NOT include quotation marks in the
Tag values, just type VVII, for example. Also, remove the quotes around the
V in the following statement:

If Mid(ctl.Tag,intCaseNumber,1) = “V†Then

and then type them back in. I typed my response in Word, and it used
different characters than Access does.

:

Hi Sprinks
thanks for Help
but tag method dose not work, I taged the check boxes and placed the code on
current event of the form and the Lasped textbox after update
I'll try to use the name property of the control.
thanks

:

Select Case Lasped
Case Is >0, Is <182
For Each ctl In Me.Controls
If ctl.ControlType = acCheckBox Then
If (ctl.Name = “Application†OR ctl.Name = “EMT†OR _
ctl.Name = “Picture†OR ctl.Name = “CE24†OR _
ctl.Name = “Fee30â€) Then ctl.Visible = True
Else
ctl.Visible = False
End If
End If
Next ctl
Case Is >182, Is <365
…similar statements here…
Case Is >365, Is <1095
…similar statements here…
Case Is >1095
…similar statements here…
End Select

This code uses the name property of the control, which makes for a
cumbersome compound OR statement. You could do something more elegant using
the Tag property of each control, which is kind of a "bonus" control Access
provides for programming convenience.

Since there are four cases, you could assign a four-character Tag for each
checkbox control corresponding whether the control should be visible for that
case or not—“V†for Visible, “I†for Invisible—then use the Mid function to
determine the value of the control for that case.

For example, “Application†is visible in all four cases, so assign a string
of “VVVV†to the Tag property. The “CE24†checkbox is only visible in the
first case, so its Tag would be “VIIIâ€

Then your Select Case statement simplifies to:

Dim intCaseNumber As Integer

Select Case Lasped
Case Is >0, Is <182 ‘ Case 1
intCaseNumber = 1
Case Is >182, Is <365 ‘ Case 2
intCaseNumber = 2
Case Is >365, Is <1095 ‘ Case 3
intCaseNumber = 3
Case Is >1095 ‘ Case 4
intCaseNumber = 4
End Select

For Each ctl In Me.Controls
If ctl.ControlType = acCheckBox Then
If Mid(ctl.Tag,intCaseNumber,1) = “V†Then
ctl.Visible = True
Else
ctl.Visible = False
End If
End If
Next ctl

Hope that helps.
Sprinks

:

I have EMT form and a subform “Requir†based on a query which is hold 10
check boxes: Application, EMT, Picture, PCR, CE24, CE36, CE48, Fee30, Fee40,
Test , ….. and a text box “ Lasped†that calculate the date deference
=(Date()-[Expiration Date]) as a control source .
what I want to do
1- If the Lasped is >0 and <182then have check boxes: Application, EMT,
Picture,
CE24, Fee30 Visible and other check boxes Invisible
2- If Lasped is >182 and <365 then have check boxes: Application, EMT,
Picture, CE48, Fee40, Test Visible and other check boxes Invisible
3- If Lasped is >365 and <1095 then have check boxes: Application, EMT,
Picture, CE48, Fee40 , Skill Visible and other check boxes Invisible
4- If Lasped is >1095 then have check boxes: Application, EMT, Picture,
Fee30, CorssCopilation Visible and other check boxes Invisible
any help
Thanks
 
Amin,

As this code worked just as I've shown it, making up my own set of Tag
cases, I can only suggest you carefully check the Tags you've assigned to be
sure they reflect which display groups the control is in. Also, you might
insert one or more MsgBox statements to assist understanding what is
happening:

Dim intCaseNumber As Integer

Select Case Lasped
Case Is >0, Is <182 ‘ Case 1
intCaseNumber = 1
Case Is >182, Is <365 ‘ Case 2
intCaseNumber = 2
Case Is >365, Is <1095 ‘ Case 3
intCaseNumber = 3
Case Is >1095 ‘ Case 4
intCaseNumber = 4
End Select

MsgBox "This is case number " & intCaseNumber

For Each ctl In Me.Controls
MsgBox "Working on control " & ctl.Name
If ctl.ControlType = acCheckBox Then
MsgBox ctl.Name & " is a check box."
If Mid(ctl.Tag,intCaseNumber,1) = "V" Then
MsgBox ctl.Name & "'s character number " & intCaseNumber & " is V".
ctl.Visible = True
Else
MsgBox ctl.Name & "'s character number " & intCaseNumber & " is not V".
ctl.Visible = False
End If
End If
Next ctl

Hope that helps.
Sprinks

amin said:
What I'm seeing is that I'm getting the same result for date range of
Case Is >182, Is <365 with the date range of Case Is >365, Is <1095




Sprinks said:
Hi, Amin.

No, the way it's written is the way it should be. How is it not working?
Are you getting an error message? What behavior are you seeing?

Sprinks

amin said:
Hi Sprinks
I guss that I need the date range to read and instead of Or for example
Case Is >182, Is <365 should be
Case Is >182 And Is <365
but this not working either
Thanks

:

Hi, Amin.

I got the code to work here.

You may have to make 2 minor changes: do NOT include quotation marks in the
Tag values, just type VVII, for example. Also, remove the quotes around the
V in the following statement:

If Mid(ctl.Tag,intCaseNumber,1) = “V†Then

and then type them back in. I typed my response in Word, and it used
different characters than Access does.

:

Hi Sprinks
thanks for Help
but tag method dose not work, I taged the check boxes and placed the code on
current event of the form and the Lasped textbox after update
I'll try to use the name property of the control.
thanks

:

Select Case Lasped
Case Is >0, Is <182
For Each ctl In Me.Controls
If ctl.ControlType = acCheckBox Then
If (ctl.Name = “Application†OR ctl.Name = “EMT†OR _
ctl.Name = “Picture†OR ctl.Name = “CE24†OR _
ctl.Name = “Fee30â€) Then ctl.Visible = True
Else
ctl.Visible = False
End If
End If
Next ctl
Case Is >182, Is <365
…similar statements here…
Case Is >365, Is <1095
…similar statements here…
Case Is >1095
…similar statements here…
End Select

This code uses the name property of the control, which makes for a
cumbersome compound OR statement. You could do something more elegant using
the Tag property of each control, which is kind of a "bonus" control Access
provides for programming convenience.

Since there are four cases, you could assign a four-character Tag for each
checkbox control corresponding whether the control should be visible for that
case or not—“V†for Visible, “I†for Invisible—then use the Mid function to
determine the value of the control for that case.

For example, “Application†is visible in all four cases, so assign a string
of “VVVV†to the Tag property. The “CE24†checkbox is only visible in the
first case, so its Tag would be “VIIIâ€

Then your Select Case statement simplifies to:

Dim intCaseNumber As Integer

Select Case Lasped
Case Is >0, Is <182 ‘ Case 1
intCaseNumber = 1
Case Is >182, Is <365 ‘ Case 2
intCaseNumber = 2
Case Is >365, Is <1095 ‘ Case 3
intCaseNumber = 3
Case Is >1095 ‘ Case 4
intCaseNumber = 4
End Select

For Each ctl In Me.Controls
If ctl.ControlType = acCheckBox Then
If Mid(ctl.Tag,intCaseNumber,1) = “V†Then
ctl.Visible = True
Else
ctl.Visible = False
End If
End If
Next ctl

Hope that helps.
Sprinks

:

I have EMT form and a subform “Requir†based on a query which is hold 10
check boxes: Application, EMT, Picture, PCR, CE24, CE36, CE48, Fee30, Fee40,
Test , ….. and a text box “ Lasped†that calculate the date deference
=(Date()-[Expiration Date]) as a control source .
what I want to do
1- If the Lasped is >0 and <182then have check boxes: Application, EMT,
Picture,
CE24, Fee30 Visible and other check boxes Invisible
2- If Lasped is >182 and <365 then have check boxes: Application, EMT,
Picture, CE48, Fee40, Test Visible and other check boxes Invisible
3- If Lasped is >365 and <1095 then have check boxes: Application, EMT,
Picture, CE48, Fee40 , Skill Visible and other check boxes Invisible
4- If Lasped is >1095 then have check boxes: Application, EMT, Picture,
Fee30, CorssCopilation Visible and other check boxes Invisible
any help
Thanks
 
thanks again Sprinks
I got an error message:
variable is not defined for Ctl
Ahmed

Sprinks said:
Amin,

As this code worked just as I've shown it, making up my own set of Tag
cases, I can only suggest you carefully check the Tags you've assigned to be
sure they reflect which display groups the control is in. Also, you might
insert one or more MsgBox statements to assist understanding what is
happening:

Dim intCaseNumber As Integer

Select Case Lasped
Case Is >0, Is <182 ‘ Case 1
intCaseNumber = 1
Case Is >182, Is <365 ‘ Case 2
intCaseNumber = 2
Case Is >365, Is <1095 ‘ Case 3
intCaseNumber = 3
Case Is >1095 ‘ Case 4
intCaseNumber = 4
End Select

MsgBox "This is case number " & intCaseNumber

For Each ctl In Me.Controls
MsgBox "Working on control " & ctl.Name
If ctl.ControlType = acCheckBox Then
MsgBox ctl.Name & " is a check box."
If Mid(ctl.Tag,intCaseNumber,1) = "V" Then
MsgBox ctl.Name & "'s character number " & intCaseNumber & " is V".
ctl.Visible = True
Else
MsgBox ctl.Name & "'s character number " & intCaseNumber & " is not V".
ctl.Visible = False
End If
End If
Next ctl

Hope that helps.
Sprinks

amin said:
What I'm seeing is that I'm getting the same result for date range of
Case Is >182, Is <365 with the date range of Case Is >365, Is <1095




Sprinks said:
Hi, Amin.

No, the way it's written is the way it should be. How is it not working?
Are you getting an error message? What behavior are you seeing?

Sprinks

:

Hi Sprinks
I guss that I need the date range to read and instead of Or for example
Case Is >182, Is <365 should be
Case Is >182 And Is <365
but this not working either
Thanks

:

Hi, Amin.

I got the code to work here.

You may have to make 2 minor changes: do NOT include quotation marks in the
Tag values, just type VVII, for example. Also, remove the quotes around the
V in the following statement:

If Mid(ctl.Tag,intCaseNumber,1) = “V†Then

and then type them back in. I typed my response in Word, and it used
different characters than Access does.

:

Hi Sprinks
thanks for Help
but tag method dose not work, I taged the check boxes and placed the code on
current event of the form and the Lasped textbox after update
I'll try to use the name property of the control.
thanks

:

Select Case Lasped
Case Is >0, Is <182
For Each ctl In Me.Controls
If ctl.ControlType = acCheckBox Then
If (ctl.Name = “Application†OR ctl.Name = “EMT†OR _
ctl.Name = “Picture†OR ctl.Name = “CE24†OR _
ctl.Name = “Fee30â€) Then ctl.Visible = True
Else
ctl.Visible = False
End If
End If
Next ctl
Case Is >182, Is <365
…similar statements here…
Case Is >365, Is <1095
…similar statements here…
Case Is >1095
…similar statements here…
End Select

This code uses the name property of the control, which makes for a
cumbersome compound OR statement. You could do something more elegant using
the Tag property of each control, which is kind of a "bonus" control Access
provides for programming convenience.

Since there are four cases, you could assign a four-character Tag for each
checkbox control corresponding whether the control should be visible for that
case or not—“V†for Visible, “I†for Invisible—then use the Mid function to
determine the value of the control for that case.

For example, “Application†is visible in all four cases, so assign a string
of “VVVV†to the Tag property. The “CE24†checkbox is only visible in the
first case, so its Tag would be “VIIIâ€

Then your Select Case statement simplifies to:

Dim intCaseNumber As Integer

Select Case Lasped
Case Is >0, Is <182 ‘ Case 1
intCaseNumber = 1
Case Is >182, Is <365 ‘ Case 2
intCaseNumber = 2
Case Is >365, Is <1095 ‘ Case 3
intCaseNumber = 3
Case Is >1095 ‘ Case 4
intCaseNumber = 4
End Select

For Each ctl In Me.Controls
If ctl.ControlType = acCheckBox Then
If Mid(ctl.Tag,intCaseNumber,1) = “V†Then
ctl.Visible = True
Else
ctl.Visible = False
End If
End If
Next ctl

Hope that helps.
Sprinks

:

I have EMT form and a subform “Requir†based on a query which is hold 10
check boxes: Application, EMT, Picture, PCR, CE24, CE36, CE48, Fee30, Fee40,
Test , ….. and a text box “ Lasped†that calculate the date deference
=(Date()-[Expiration Date]) as a control source .
what I want to do
1- If the Lasped is >0 and <182then have check boxes: Application, EMT,
Picture,
CE24, Fee30 Visible and other check boxes Invisible
2- If Lasped is >182 and <365 then have check boxes: Application, EMT,
Picture, CE48, Fee40, Test Visible and other check boxes Invisible
3- If Lasped is >365 and <1095 then have check boxes: Application, EMT,
Picture, CE48, Fee40 , Skill Visible and other check boxes Invisible
4- If Lasped is >1095 then have check boxes: Application, EMT, Picture,
Fee30, CorssCopilation Visible and other check boxes Invisible
any help
Thanks
 
Aha!

Sorry, if I omitted this earlier, Amin. Dimension the variable at the top
of the code:

Dim ctl As Control

Sprinks

amin said:
thanks again Sprinks
I got an error message:
variable is not defined for Ctl
Ahmed

Sprinks said:
Amin,

As this code worked just as I've shown it, making up my own set of Tag
cases, I can only suggest you carefully check the Tags you've assigned to be
sure they reflect which display groups the control is in. Also, you might
insert one or more MsgBox statements to assist understanding what is
happening:

Dim intCaseNumber As Integer

Select Case Lasped
Case Is >0, Is <182 ‘ Case 1
intCaseNumber = 1
Case Is >182, Is <365 ‘ Case 2
intCaseNumber = 2
Case Is >365, Is <1095 ‘ Case 3
intCaseNumber = 3
Case Is >1095 ‘ Case 4
intCaseNumber = 4
End Select

MsgBox "This is case number " & intCaseNumber

For Each ctl In Me.Controls
MsgBox "Working on control " & ctl.Name
If ctl.ControlType = acCheckBox Then
MsgBox ctl.Name & " is a check box."
If Mid(ctl.Tag,intCaseNumber,1) = "V" Then
MsgBox ctl.Name & "'s character number " & intCaseNumber & " is V".
ctl.Visible = True
Else
MsgBox ctl.Name & "'s character number " & intCaseNumber & " is not V".
ctl.Visible = False
End If
End If
Next ctl

Hope that helps.
Sprinks

amin said:
What I'm seeing is that I'm getting the same result for date range of
Case Is >182, Is <365 with the date range of Case Is >365, Is <1095




:

Hi, Amin.

No, the way it's written is the way it should be. How is it not working?
Are you getting an error message? What behavior are you seeing?

Sprinks

:

Hi Sprinks
I guss that I need the date range to read and instead of Or for example
Case Is >182, Is <365 should be
Case Is >182 And Is <365
but this not working either
Thanks

:

Hi, Amin.

I got the code to work here.

You may have to make 2 minor changes: do NOT include quotation marks in the
Tag values, just type VVII, for example. Also, remove the quotes around the
V in the following statement:

If Mid(ctl.Tag,intCaseNumber,1) = “V†Then

and then type them back in. I typed my response in Word, and it used
different characters than Access does.

:

Hi Sprinks
thanks for Help
but tag method dose not work, I taged the check boxes and placed the code on
current event of the form and the Lasped textbox after update
I'll try to use the name property of the control.
thanks

:

Select Case Lasped
Case Is >0, Is <182
For Each ctl In Me.Controls
If ctl.ControlType = acCheckBox Then
If (ctl.Name = “Application†OR ctl.Name = “EMT†OR _
ctl.Name = “Picture†OR ctl.Name = “CE24†OR _
ctl.Name = “Fee30â€) Then ctl.Visible = True
Else
ctl.Visible = False
End If
End If
Next ctl
Case Is >182, Is <365
…similar statements here…
Case Is >365, Is <1095
…similar statements here…
Case Is >1095
…similar statements here…
End Select

This code uses the name property of the control, which makes for a
cumbersome compound OR statement. You could do something more elegant using
the Tag property of each control, which is kind of a "bonus" control Access
provides for programming convenience.

Since there are four cases, you could assign a four-character Tag for each
checkbox control corresponding whether the control should be visible for that
case or not—“V†for Visible, “I†for Invisible—then use the Mid function to
determine the value of the control for that case.

For example, “Application†is visible in all four cases, so assign a string
of “VVVV†to the Tag property. The “CE24†checkbox is only visible in the
first case, so its Tag would be “VIIIâ€

Then your Select Case statement simplifies to:

Dim intCaseNumber As Integer

Select Case Lasped
Case Is >0, Is <182 ‘ Case 1
intCaseNumber = 1
Case Is >182, Is <365 ‘ Case 2
intCaseNumber = 2
Case Is >365, Is <1095 ‘ Case 3
intCaseNumber = 3
Case Is >1095 ‘ Case 4
intCaseNumber = 4
End Select

For Each ctl In Me.Controls
If ctl.ControlType = acCheckBox Then
If Mid(ctl.Tag,intCaseNumber,1) = “V†Then
ctl.Visible = True
Else
ctl.Visible = False
End If
End If
Next ctl

Hope that helps.
Sprinks

:

I have EMT form and a subform “Requir†based on a query which is hold 10
check boxes: Application, EMT, Picture, PCR, CE24, CE36, CE48, Fee30, Fee40,
Test , ….. and a text box “ Lasped†that calculate the date deference
=(Date()-[Expiration Date]) as a control source .
what I want to do
1- If the Lasped is >0 and <182then have check boxes: Application, EMT,
Picture,
CE24, Fee30 Visible and other check boxes Invisible
2- If Lasped is >182 and <365 then have check boxes: Application, EMT,
Picture, CE48, Fee40, Test Visible and other check boxes Invisible
3- If Lasped is >365 and <1095 then have check boxes: Application, EMT,
Picture, CE48, Fee40 , Skill Visible and other check boxes Invisible
4- If Lasped is >1095 then have check boxes: Application, EMT, Picture,
Fee30, CorssCopilation Visible and other check boxes Invisible
any help
Thanks
 
Hi Sprinks
this is exactly what I did. is to dim as control.
then I checked all my tags all were OK, added all Message boxes, I found out
that some of them were wrong.
then I did compact and repair. It did fix the problem
Thanks Again

Sprinks said:
Aha!

Sorry, if I omitted this earlier, Amin. Dimension the variable at the top
of the code:

Dim ctl As Control

Sprinks

amin said:
thanks again Sprinks
I got an error message:
variable is not defined for Ctl
Ahmed

Sprinks said:
Amin,

As this code worked just as I've shown it, making up my own set of Tag
cases, I can only suggest you carefully check the Tags you've assigned to be
sure they reflect which display groups the control is in. Also, you might
insert one or more MsgBox statements to assist understanding what is
happening:

Dim intCaseNumber As Integer

Select Case Lasped
Case Is >0, Is <182 ‘ Case 1
intCaseNumber = 1
Case Is >182, Is <365 ‘ Case 2
intCaseNumber = 2
Case Is >365, Is <1095 ‘ Case 3
intCaseNumber = 3
Case Is >1095 ‘ Case 4
intCaseNumber = 4
End Select

MsgBox "This is case number " & intCaseNumber

For Each ctl In Me.Controls
MsgBox "Working on control " & ctl.Name
If ctl.ControlType = acCheckBox Then
MsgBox ctl.Name & " is a check box."
If Mid(ctl.Tag,intCaseNumber,1) = "V" Then
MsgBox ctl.Name & "'s character number " & intCaseNumber & " is V".
ctl.Visible = True
Else
MsgBox ctl.Name & "'s character number " & intCaseNumber & " is not V".
ctl.Visible = False
End If
End If
Next ctl

Hope that helps.
Sprinks

:

What I'm seeing is that I'm getting the same result for date range of
Case Is >182, Is <365 with the date range of Case Is >365, Is <1095




:

Hi, Amin.

No, the way it's written is the way it should be. How is it not working?
Are you getting an error message? What behavior are you seeing?

Sprinks

:

Hi Sprinks
I guss that I need the date range to read and instead of Or for example
Case Is >182, Is <365 should be
Case Is >182 And Is <365
but this not working either
Thanks

:

Hi, Amin.

I got the code to work here.

You may have to make 2 minor changes: do NOT include quotation marks in the
Tag values, just type VVII, for example. Also, remove the quotes around the
V in the following statement:

If Mid(ctl.Tag,intCaseNumber,1) = “V†Then

and then type them back in. I typed my response in Word, and it used
different characters than Access does.

:

Hi Sprinks
thanks for Help
but tag method dose not work, I taged the check boxes and placed the code on
current event of the form and the Lasped textbox after update
I'll try to use the name property of the control.
thanks

:

Select Case Lasped
Case Is >0, Is <182
For Each ctl In Me.Controls
If ctl.ControlType = acCheckBox Then
If (ctl.Name = “Application†OR ctl.Name = “EMT†OR _
ctl.Name = “Picture†OR ctl.Name = “CE24†OR _
ctl.Name = “Fee30â€) Then ctl.Visible = True
Else
ctl.Visible = False
End If
End If
Next ctl
Case Is >182, Is <365
…similar statements here…
Case Is >365, Is <1095
…similar statements here…
Case Is >1095
…similar statements here…
End Select

This code uses the name property of the control, which makes for a
cumbersome compound OR statement. You could do something more elegant using
the Tag property of each control, which is kind of a "bonus" control Access
provides for programming convenience.

Since there are four cases, you could assign a four-character Tag for each
checkbox control corresponding whether the control should be visible for that
case or not—“V†for Visible, “I†for Invisible—then use the Mid function to
determine the value of the control for that case.

For example, “Application†is visible in all four cases, so assign a string
of “VVVV†to the Tag property. The “CE24†checkbox is only visible in the
first case, so its Tag would be “VIIIâ€

Then your Select Case statement simplifies to:

Dim intCaseNumber As Integer

Select Case Lasped
Case Is >0, Is <182 ‘ Case 1
intCaseNumber = 1
Case Is >182, Is <365 ‘ Case 2
intCaseNumber = 2
Case Is >365, Is <1095 ‘ Case 3
intCaseNumber = 3
Case Is >1095 ‘ Case 4
intCaseNumber = 4
End Select

For Each ctl In Me.Controls
If ctl.ControlType = acCheckBox Then
If Mid(ctl.Tag,intCaseNumber,1) = “V†Then
ctl.Visible = True
Else
ctl.Visible = False
End If
End If
Next ctl

Hope that helps.
Sprinks

:

I have EMT form and a subform “Requir†based on a query which is hold 10
check boxes: Application, EMT, Picture, PCR, CE24, CE36, CE48, Fee30, Fee40,
Test , ….. and a text box “ Lasped†that calculate the date deference
=(Date()-[Expiration Date]) as a control source .
what I want to do
1- If the Lasped is >0 and <182then have check boxes: Application, EMT,
Picture,
CE24, Fee30 Visible and other check boxes Invisible
2- If Lasped is >182 and <365 then have check boxes: Application, EMT,
Picture, CE48, Fee40, Test Visible and other check boxes Invisible
3- If Lasped is >365 and <1095 then have check boxes: Application, EMT,
Picture, CE48, Fee40 , Skill Visible and other check boxes Invisible
4- If Lasped is >1095 then have check boxes: Application, EMT, Picture,
Fee30, CorssCopilation Visible and other check boxes Invisible
any help
Thanks
 
Glad it worked out. My pleasure.

amin said:
Hi Sprinks
this is exactly what I did. is to dim as control.
then I checked all my tags all were OK, added all Message boxes, I found out
that some of them were wrong.
then I did compact and repair. It did fix the problem
Thanks Again

Sprinks said:
Aha!

Sorry, if I omitted this earlier, Amin. Dimension the variable at the top
of the code:

Dim ctl As Control

Sprinks

amin said:
thanks again Sprinks
I got an error message:
variable is not defined for Ctl
Ahmed

:

Amin,

As this code worked just as I've shown it, making up my own set of Tag
cases, I can only suggest you carefully check the Tags you've assigned to be
sure they reflect which display groups the control is in. Also, you might
insert one or more MsgBox statements to assist understanding what is
happening:

Dim intCaseNumber As Integer

Select Case Lasped
Case Is >0, Is <182 ‘ Case 1
intCaseNumber = 1
Case Is >182, Is <365 ‘ Case 2
intCaseNumber = 2
Case Is >365, Is <1095 ‘ Case 3
intCaseNumber = 3
Case Is >1095 ‘ Case 4
intCaseNumber = 4
End Select

MsgBox "This is case number " & intCaseNumber

For Each ctl In Me.Controls
MsgBox "Working on control " & ctl.Name
If ctl.ControlType = acCheckBox Then
MsgBox ctl.Name & " is a check box."
If Mid(ctl.Tag,intCaseNumber,1) = "V" Then
MsgBox ctl.Name & "'s character number " & intCaseNumber & " is V".
ctl.Visible = True
Else
MsgBox ctl.Name & "'s character number " & intCaseNumber & " is not V".
ctl.Visible = False
End If
End If
Next ctl

Hope that helps.
Sprinks

:

What I'm seeing is that I'm getting the same result for date range of
Case Is >182, Is <365 with the date range of Case Is >365, Is <1095




:

Hi, Amin.

No, the way it's written is the way it should be. How is it not working?
Are you getting an error message? What behavior are you seeing?

Sprinks

:

Hi Sprinks
I guss that I need the date range to read and instead of Or for example
Case Is >182, Is <365 should be
Case Is >182 And Is <365
but this not working either
Thanks

:

Hi, Amin.

I got the code to work here.

You may have to make 2 minor changes: do NOT include quotation marks in the
Tag values, just type VVII, for example. Also, remove the quotes around the
V in the following statement:

If Mid(ctl.Tag,intCaseNumber,1) = “V†Then

and then type them back in. I typed my response in Word, and it used
different characters than Access does.

:

Hi Sprinks
thanks for Help
but tag method dose not work, I taged the check boxes and placed the code on
current event of the form and the Lasped textbox after update
I'll try to use the name property of the control.
thanks

:

Select Case Lasped
Case Is >0, Is <182
For Each ctl In Me.Controls
If ctl.ControlType = acCheckBox Then
If (ctl.Name = “Application†OR ctl.Name = “EMT†OR _
ctl.Name = “Picture†OR ctl.Name = “CE24†OR _
ctl.Name = “Fee30â€) Then ctl.Visible = True
Else
ctl.Visible = False
End If
End If
Next ctl
Case Is >182, Is <365
…similar statements here…
Case Is >365, Is <1095
…similar statements here…
Case Is >1095
…similar statements here…
End Select

This code uses the name property of the control, which makes for a
cumbersome compound OR statement. You could do something more elegant using
the Tag property of each control, which is kind of a "bonus" control Access
provides for programming convenience.

Since there are four cases, you could assign a four-character Tag for each
checkbox control corresponding whether the control should be visible for that
case or not—“V†for Visible, “I†for Invisible—then use the Mid function to
determine the value of the control for that case.

For example, “Application†is visible in all four cases, so assign a string
of “VVVV†to the Tag property. The “CE24†checkbox is only visible in the
first case, so its Tag would be “VIIIâ€

Then your Select Case statement simplifies to:

Dim intCaseNumber As Integer

Select Case Lasped
Case Is >0, Is <182 ‘ Case 1
intCaseNumber = 1
Case Is >182, Is <365 ‘ Case 2
intCaseNumber = 2
Case Is >365, Is <1095 ‘ Case 3
intCaseNumber = 3
Case Is >1095 ‘ Case 4
intCaseNumber = 4
End Select

For Each ctl In Me.Controls
If ctl.ControlType = acCheckBox Then
If Mid(ctl.Tag,intCaseNumber,1) = “V†Then
ctl.Visible = True
Else
ctl.Visible = False
End If
End If
Next ctl

Hope that helps.
Sprinks

:

I have EMT form and a subform “Requir†based on a query which is hold 10
check boxes: Application, EMT, Picture, PCR, CE24, CE36, CE48, Fee30, Fee40,
Test , ….. and a text box “ Lasped†that calculate the date deference
=(Date()-[Expiration Date]) as a control source .
what I want to do
1- If the Lasped is >0 and <182then have check boxes: Application, EMT,
Picture,
CE24, Fee30 Visible and other check boxes Invisible
2- If Lasped is >182 and <365 then have check boxes: Application, EMT,
Picture, CE48, Fee40, Test Visible and other check boxes Invisible
3- If Lasped is >365 and <1095 then have check boxes: Application, EMT,
Picture, CE48, Fee40 , Skill Visible and other check boxes Invisible
4- If Lasped is >1095 then have check boxes: Application, EMT, Picture,
Fee30, CorssCopilation Visible and other check boxes Invisible
any help
Thanks
 
Back
Top