Visable

G

Guest

I am trying to make a text box visable with certain critera.
I know to put it under OnCurrent
IIF([Text2]=>13,[Employee-Instate Page1].Visable
IIF([Text2]=<14,[Employee-Instate Page2].Visable
But then what?
This is where I get confused.
Thanks for your help
Chey
 
D

Dirk Goldgar

Chey said:
I am trying to make a text box visable with certain critera.
I know to put it under OnCurrent
IIF([Text2]=>13,[Employee-Instate Page1].Visable
IIF([Text2]=<14,[Employee-Instate Page2].Visable
But then what?
This is where I get confused.
Thanks for your help
Chey

IIf() is a function that returns a value, so it's not quite appropriate
for what you're trying to do. Furthermore, the property is named
"Visible", not "Visable". I think what you want is an event procedure
something like this:

'----- start of suggested code -----
Private Sub Form_Current()

Me.[Employee-Instate Page1].Visible = (Me.[Text2] >= 13)
Me.[Employee-Instate Page2].Visible = (Me.[Text2] <= 14)

End Sub
'----- end of suggested code -----
 
G

Guest

Okay I must of written something wrong. If it is 13 or less then
Employee-Instate Page 1
If 14 or more then Employee-Instate Page2
I opened one that is exactly 13 and it made Page2 Visable.
Thanks

Dirk Goldgar said:
Chey said:
I am trying to make a text box visable with certain critera.
I know to put it under OnCurrent
IIF([Text2]=>13,[Employee-Instate Page1].Visable
IIF([Text2]=<14,[Employee-Instate Page2].Visable
But then what?
This is where I get confused.
Thanks for your help
Chey

IIf() is a function that returns a value, so it's not quite appropriate
for what you're trying to do. Furthermore, the property is named
"Visible", not "Visable". I think what you want is an event procedure
something like this:

'----- start of suggested code -----
Private Sub Form_Current()

Me.[Employee-Instate Page1].Visible = (Me.[Text2] >= 13)
Me.[Employee-Instate Page2].Visible = (Me.[Text2] <= 14)

End Sub
'----- end of suggested code -----

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
D

Dirk Goldgar

Chey said:
Okay I must of written something wrong. If it is 13 or less then
Employee-Instate Page 1
If 14 or more then Employee-Instate Page2
IIF([Text2]=>13,[Employee-Instate Page1].Visable
IIF([Text2]=<14,[Employee-Instate Page2].Visable

So try it this way:

Me.[Employee-Instate Page1].Visible = (Me.[Text2] <= 13)
Me.[Employee-Instate Page2].Visible = (Me.[Text2] >= 14)

Although, since now you've described an exclusive set of conditions, it
would be better to write it like this:

If Me.[Text2] <= 13 Then
Me.[Employee-Instate Page1].Visible = True
Me.[Employee-Instate Page2].Visible = False
Else
Me.[Employee-Instate Page1].Visible = False
Me.[Employee-Instate Page2].Visible = True
End If
 
G

Guest

Sorry to bother you again.
So I pasted what you gave me and it said complie error expected )
So I added that in before .visable
Now it says argument not optional.
it highlights the IIf

Dirk Goldgar said:
Chey said:
Okay I must of written something wrong. If it is 13 or less then
Employee-Instate Page 1
If 14 or more then Employee-Instate Page2
IIF([Text2]=>13,[Employee-Instate Page1].Visable
IIF([Text2]=<14,[Employee-Instate Page2].Visable

So try it this way:

Me.[Employee-Instate Page1].Visible = (Me.[Text2] <= 13)
Me.[Employee-Instate Page2].Visible = (Me.[Text2] >= 14)

Although, since now you've described an exclusive set of conditions, it
would be better to write it like this:

If Me.[Text2] <= 13 Then
Me.[Employee-Instate Page1].Visible = True
Me.[Employee-Instate Page2].Visible = False
Else
Me.[Employee-Instate Page1].Visible = False
Me.[Employee-Instate Page2].Visible = True
End If

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
G

Guest

I tried all the examples it seems to make the same on visable either way. If
I change the signs around then it only shows the other visable. It is not
switching between the two. When I view on that is 13 it makes page1 visable
when I view one that is 25 same thing page1 if I change the signs around it
only makes page2 visable.
Any other suggestions
Thanks for your time.
Chey

Dirk Goldgar said:
Chey said:
Okay I must of written something wrong. If it is 13 or less then
Employee-Instate Page 1
If 14 or more then Employee-Instate Page2
IIF([Text2]=>13,[Employee-Instate Page1].Visable
IIF([Text2]=<14,[Employee-Instate Page2].Visable

So try it this way:

Me.[Employee-Instate Page1].Visible = (Me.[Text2] <= 13)
Me.[Employee-Instate Page2].Visible = (Me.[Text2] >= 14)

Although, since now you've described an exclusive set of conditions, it
would be better to write it like this:

If Me.[Text2] <= 13 Then
Me.[Employee-Instate Page1].Visible = True
Me.[Employee-Instate Page2].Visible = False
Else
Me.[Employee-Instate Page1].Visible = False
Me.[Employee-Instate Page2].Visible = True
End If

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
D

Dirk Goldgar

Chey said:
Sorry to bother you again.
So I pasted what you gave me and it said complie error expected )
So I added that in before .visable
Now it says argument not optional.
it highlights the IIf

There must be a misunderstanding. The code that I suggested you use was
this:

If Me.[Text2] <= 13 Then
Me.[Employee-Instate Page1].Visible = True
Me.[Employee-Instate Page2].Visible = False
Else
Me.[Employee-Instate Page1].Visible = False
Me.[Employee-Instate Page2].Visible = True
End If

There is no "IIf" expression. Furthermore, I don't see any way it could
give you a compile error, so long as your form contains controls named
"Text2", "Employee-Instate Page1", and "Employee-Instate Page2", which
are the names in your original post.
 
D

Dirk Goldgar

Chey said:
I tried all the examples it seems to make the same on visable either
way. If I change the signs around then it only shows the other
visable. It is not switching between the two. When I view on that
is 13 it makes page1 visable when I view one that is 25 same thing
page1 if I change the signs around it only makes page2 visable.

It doesn't behave that way on my test form. Please post exactly what
you have as the form's Current event procedure. Use copy/paste to put
the code into your message, to avoid any transcription errors.

One possibility that occurs to me is, what type of field is the Text2
control bound to? Could it be Text, perhaps? I was assuming it's a
Number field; if it's a Text field the comparison will not be correct.
 
G

Guest

Private Sub Form_Current()
If Me.[Text2] <= 13 Then
Me.[Employee-InState Page1].Visible = True
Me.[Employee-Instate Page2].Visible = False
Else
Me.[Employee-InState Page1].Visible = False
Me.[Employee-Instate Page2].Visible = True
End If


End Sub
I made sure the spelling was correct and I made the unbound field number in
the format I put #. Other than that I created an unbound field on a subform.
Then on my main form I have the unbound field equal to the one on the
subform. That is my Text2.
 
D

Dirk Goldgar

Chey said:
Private Sub Form_Current()
If Me.[Text2] <= 13 Then
Me.[Employee-InState Page1].Visible = True
Me.[Employee-Instate Page2].Visible = False
Else
Me.[Employee-InState Page1].Visible = False
Me.[Employee-Instate Page2].Visible = True
End If


End Sub

I assume you don't get any compile errors with this code.
I made sure the spelling was correct and I made the unbound field
number in the format I put #. Other than that I created an unbound
field on a subform. Then on my main form I have the unbound field
equal to the one on the subform. That is my Text2.

I wonder if Access is confused about the data type, since you've got two
levels of indirection. What are the values of the ControlSource
properties of Text2 and of the control on the subform?

As a test, you might see if it works with this "If" statement instead of
the original one:

If Val(Me.[Text2]) <= 13 Then
 
G

Guest

I tried the new on you gave me. I still get the same result.
On my subform
=Count(*) in the unbound text field. I set the Format to #
On the main form
=[TA_Number_Start Idomize].Form![Amount_Vendor_Date subform].Form!Text20
This is Text2 I also set the format to #
Thanks


Dirk Goldgar said:
Chey said:
Private Sub Form_Current()
If Me.[Text2] <= 13 Then
Me.[Employee-InState Page1].Visible = True
Me.[Employee-Instate Page2].Visible = False
Else
Me.[Employee-InState Page1].Visible = False
Me.[Employee-Instate Page2].Visible = True
End If


End Sub

I assume you don't get any compile errors with this code.
I made sure the spelling was correct and I made the unbound field
number in the format I put #. Other than that I created an unbound
field on a subform. Then on my main form I have the unbound field
equal to the one on the subform. That is my Text2.

I wonder if Access is confused about the data type, since you've got two
levels of indirection. What are the values of the ControlSource
properties of Text2 and of the control on the subform?

As a test, you might see if it works with this "If" statement instead of
the original one:

If Val(Me.[Text2]) <= 13 Then


--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
D

Dirk Goldgar

Chey said:
I tried the new on you gave me. I still get the same result.
On my subform
=Count(*) in the unbound text field. I set the Format to #
On the main form
=[TA_Number_Start Idomize].Form![Amount_Vendor_Date
subform].Form!Text20 This is Text2 I also set the format to #

Is that two levels of subform, so that Text2 is on a sub-sub-form?

I'm wondering if this is a timing problem, if the subform(s) take some
time to load.
 
D

Dirk Goldgar

Chey said:
Text20 is on the subform and Text2 is on the main form. Should I put
the code under after update?

Dirk Goldgar said:
Chey said:
I tried the new on you gave me. I still get the same result.
On my subform
=Count(*) in the unbound text field. I set the Format to #
On the main form
=[TA_Number_Start Idomize].Form![Amount_Vendor_Date
subform].Form!Text20 This is Text2 I also set the format to #

Is that two levels of subform, so that Text2 is on a sub-sub-form?

I'm wondering if this is a timing problem, if the subform(s) take
some time to load.

I should have asked, "Is Text20 on a sub-sub-form?" What is
"TA_Number_Start Idomize"? Is that the name of the main form, which
holds the text box "Text2"?

Your expression implies that there is a main form, a subform named
"TA_Number_Start Idomize", and a sub-subform named "Amount_Vendor_Date
subform". If that's wrong, if "TA_Number_Start Idomize" is the name of
the main form, then the controlsource expression for Text2 should just
be:

=[Amount_Vendor_Date subform].[Form]![Text20]

That may not fix your problem, but it would be a start ... *if* there's
only a main form with one level of subform.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top