if statement help

B

blake7

Hi All, I have a form with an option group on it, it has 4 values which it is
storing in a table, I would like to make a text box disappear when one of the
radio buttons is selected, I have tried the code below in the After_update of
the form but it does not work, what is wrong? Thanks.


If Me.Option66 = True Then
Me.Text59.Visible = False
Else
Me.Text59.Visible = True
End If
 
D

Dirk Goldgar

blake7 said:
Hi All, I have a form with an option group on it, it has 4 values which it
is
storing in a table, I would like to make a text box disappear when one of
the
radio buttons is selected, I have tried the code below in the After_update
of
the form but it does not work, what is wrong? Thanks.


If Me.Option66 = True Then
Me.Text59.Visible = False
Else
Me.Text59.Visible = True
End If


Is Option66 the name of the option frame or of the option button in the
frame? You need to check the value of the option frame control, and compare
it to the Option Value of the option button. As you add option buttons --
or other option controls -- to an option frame, each button is assigned its
own Option Value, which will be the value of the option frame when that
button is selected.
 
B

blake7

Hi Dirk, yes option66 is the name of the option button and not the frame, how
should my code look? thanks for answering
 
B

blake7

Hi Dirk, tried this below but no luck, the default value of the frame63 is 3,
the stored value of option66 is 1

Private Sub Form_AfterUpdate()
If Me.Frame63.Value = 1 Then
Me.Text59.Visible = False
Else
Me.Text59.Visible = True
End If
End Sub
 
D

Dirk Goldgar

blake7 said:
Hi Dirk, tried this below but no luck, the default value of the frame63 is
3,
the stored value of option66 is 1

Private Sub Form_AfterUpdate()
If Me.Frame63.Value = 1 Then
Me.Text59.Visible = False
Else
Me.Text59.Visible = True
End If
End Sub


It would help if you said exactly what you mean by "no luck". Do you get an
error message? Does nothing at all happen, or does something happen that
shouldn't?

On the off chance that you are just using the wrong event for this, it seems
to me that I might use the form's Current event and the option frame's
AfterUpdate event for this. I would probably code those like this:

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

Me.Text59.Visible = (Nz(Me.Frame63, 0) <> 1)

End Sub

Private Sub Frame63_AfterUpdate()

Me.Text59.Visible = (Nz(Me.Frame63, 0) <> 1)

End Sub
'------ end of code ------
 
B

blake7

Hi Dirk,
Sorry for not explaining correctly and using a comment like "no luck" I have
placed your code where you stated and it works just fine, I need to learn
about where to put code as there are so many options available, will i get an
explanation in the help files?
Thanks again
Tony.
p.s one more question, is it possible to store the results of the code below
in a table field?, the code below is in a text box on my form. Thanks

=IIf(DateDiff("d",Date(),CVDate([Date Sent]))>14,"Overdue","Waiting")
 
D

Dirk Goldgar

blake7 said:
Sorry for not explaining correctly and using a comment like "no luck"

No problem, it just saves us from guessing.
I have
placed your code where you stated and it works just fine,

Very good.
I need to learn
about where to put code as there are so many options available, will i get
an
explanation in the help files?

Not directly, as there are too many different possibilities for what you
might be trying to accomplish. What you will find in the help file is a
description of the various events and when they fire. For example, see the
help topic, "Order of events for database objects". With that information,
you can consider which event or events are appropriate for a given process.
p.s one more question, is it possible to store the results of the code
below
in a table field?, the code below is in a text box on my form. Thanks

=IIf(DateDiff("d",Date(),CVDate([Date Sent]))>14,"Overdue","Waiting")

Why would you want to store that value in a field? The result of the
expression will change from one day to the next. It's normally a bad idea
to store calculated values, and while there are occasions where it is
necessary -- to preserve a snapshot of the calculation at a given time -- a
status that is based on the date would seem to be so ephemeral that I can't
understand why you would store it.
 

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

Top