Checkbox field to enable a form field

A

amelia

I have a checkbox that has the option to choose [type of payment] if the
person chooses "check" as the type of payment I want [check number] visible
to the user and also required to be filled in. I have tried different things,
but I am new to writing these in Visual Basic.

I am going into the form, design view, go to properties for [type of
payment] and going to after update. I want to create an event procedure. Any
one have an idea of what code to use?

I have tried:

Private Sub Type_of_Payment_AfterUpdate()
IIf ([type of payment] = "check" then me![check number].Visible=true)
else me![check number].Visible=false end IIF

End Sub
 
M

M Skabialka

IIF is used in a query, you need IF with one "I"

Private Sub Type_of_Payment_AfterUpdate()
If [type of payment] = "check" Then
Me![check number].Visible = True
Else
Me![check number].Visible = False
End If
End Sub
 
F

fredg

I have a checkbox that has the option to choose [type of payment] if the
person chooses "check" as the type of payment I want [check number] visible
to the user and also required to be filled in. I have tried different things,
but I am new to writing these in Visual Basic.

I am going into the form, design view, go to properties for [type of
payment] and going to after update. I want to create an event procedure. Any
one have an idea of what code to use?

I have tried:

Private Sub Type_of_Payment_AfterUpdate()
IIf ([type of payment] = "check" then me![check number].Visible=true)
else me![check number].Visible=false end IIF

End Sub

You are miss-using the IIf function here.
It should be If.
Look up the IIf and also the If...Then...Else Statement in VBA help.

Code the [Type_of_Payment] AfterUpdate event:

Me.[Check_Number].Visible = Me.[Type_of_Payment] = "Check"

Place the same code in the form's Current event as well.
 
A

Amelia

This did not work. It gives me a run-time error '13' : type mismatch

I have the field [check number] properties set to visible=no. Should I have
it left like this?

I am pulling the information from a query, so should I do the code in the
query and not in the form?



M Skabialka said:
IIF is used in a query, you need IF with one "I"

Private Sub Type_of_Payment_AfterUpdate()
If [type of payment] = "check" Then
Me![check number].Visible = True
Else
Me![check number].Visible = False
End If
End Sub

amelia said:
I have a checkbox that has the option to choose [type of payment] if the
person chooses "check" as the type of payment I want [check number]
visible
to the user and also required to be filled in. I have tried different
things,
but I am new to writing these in Visual Basic.

I am going into the form, design view, go to properties for [type of
payment] and going to after update. I want to create an event procedure.
Any
one have an idea of what code to use?

I have tried:

Private Sub Type_of_Payment_AfterUpdate()
IIf ([type of payment] = "check" then me![check number].Visible=true)
else me![check number].Visible=false end IIF

End Sub
 
M

M Skabialka

Which line gives you the error?
When you get the error, press CTRL-Break to get into the code. The line
highlighted in yellow is where the error is occuring.
I suspect it is your [type of payment]. Did they choose a text selection of
the word "check" as your statement implies, or is this a check box whose
value is True or False? If so, your statement should say:
If [type of payment] = True Then


Amelia said:
This did not work. It gives me a run-time error '13' : type mismatch

I have the field [check number] properties set to visible=no. Should I
have
it left like this?

I am pulling the information from a query, so should I do the code in the
query and not in the form?



M Skabialka said:
IIF is used in a query, you need IF with one "I"

Private Sub Type_of_Payment_AfterUpdate()
If [type of payment] = "check" Then
Me![check number].Visible = True
Else
Me![check number].Visible = False
End If
End Sub

amelia said:
I have a checkbox that has the option to choose [type of payment] if the
person chooses "check" as the type of payment I want [check number]
visible
to the user and also required to be filled in. I have tried different
things,
but I am new to writing these in Visual Basic.

I am going into the form, design view, go to properties for [type of
payment] and going to after update. I want to create an event
procedure.
Any
one have an idea of what code to use?

I have tried:

Private Sub Type_of_Payment_AfterUpdate()
IIf ([type of payment] = "check" then me![check number].Visible=true)
else me![check number].Visible=false end IIF

End Sub
 
A

Amelia

this line:

If [type of payment] = "check" Then

"check" is one of the options I have by a check box. My options are "cash",
"check", "credit card", "money order", "other"

Should I be using something here instead of "check"

M Skabialka said:
Which line gives you the error?
When you get the error, press CTRL-Break to get into the code. The line
highlighted in yellow is where the error is occuring.
I suspect it is your [type of payment]. Did they choose a text selection of
the word "check" as your statement implies, or is this a check box whose
value is True or False? If so, your statement should say:
If [type of payment] = True Then


Amelia said:
This did not work. It gives me a run-time error '13' : type mismatch

I have the field [check number] properties set to visible=no. Should I
have
it left like this?

I am pulling the information from a query, so should I do the code in the
query and not in the form?



M Skabialka said:
IIF is used in a query, you need IF with one "I"

Private Sub Type_of_Payment_AfterUpdate()
If [type of payment] = "check" Then
Me![check number].Visible = True
Else
Me![check number].Visible = False
End If
End Sub

I have a checkbox that has the option to choose [type of payment] if the
person chooses "check" as the type of payment I want [check number]
visible
to the user and also required to be filled in. I have tried different
things,
but I am new to writing these in Visual Basic.

I am going into the form, design view, go to properties for [type of
payment] and going to after update. I want to create an event
procedure.
Any
one have an idea of what code to use?

I have tried:

Private Sub Type_of_Payment_AfterUpdate()
IIf ([type of payment] = "check" then me![check number].Visible=true)
else me![check number].Visible=false end IIF

End Sub
 
M

Mrs. Ugh

You are correct. Your [type of payment] field is not a text field. You need
to look at your formand find out what the real value of the "check" option
is. It sounds like you have an option group (a box on the form with a
checkbox for each option). If so, open your form in design view and open the
properties of the "check" option. Under the data tab, you will see "option
value". This is the real value of the [type of payment] field when "check" is
selected. Just change your statement to be If [type of payment] = x (where x
is the number in the option value) and it should work.
Jill

Amelia said:
this line:

If [type of payment] = "check" Then

"check" is one of the options I have by a check box. My options are "cash",
"check", "credit card", "money order", "other"

Should I be using something here instead of "check"

M Skabialka said:
Which line gives you the error?
When you get the error, press CTRL-Break to get into the code. The line
highlighted in yellow is where the error is occuring.
I suspect it is your [type of payment]. Did they choose a text selection of
the word "check" as your statement implies, or is this a check box whose
value is True or False? If so, your statement should say:
If [type of payment] = True Then


Amelia said:
This did not work. It gives me a run-time error '13' : type mismatch

I have the field [check number] properties set to visible=no. Should I
have
it left like this?

I am pulling the information from a query, so should I do the code in the
query and not in the form?



:

IIF is used in a query, you need IF with one "I"

Private Sub Type_of_Payment_AfterUpdate()
If [type of payment] = "check" Then
Me![check number].Visible = True
Else
Me![check number].Visible = False
End If
End Sub

I have a checkbox that has the option to choose [type of payment] if the
person chooses "check" as the type of payment I want [check number]
visible
to the user and also required to be filled in. I have tried different
things,
but I am new to writing these in Visual Basic.

I am going into the form, design view, go to properties for [type of
payment] and going to after update. I want to create an event
procedure.
Any
one have an idea of what code to use?

I have tried:

Private Sub Type_of_Payment_AfterUpdate()
IIf ([type of payment] = "check" then me![check number].Visible=true)
else me![check number].Visible=false end IIF

End Sub
 
A

Amelia

It is a combo box with the options mentioned before. When I go to the data,
my row source is what I have listed in my previous post. So this is why I am
not sure why it is not working.

M Skabialka said:
Which line gives you the error?
When you get the error, press CTRL-Break to get into the code. The line
highlighted in yellow is where the error is occuring.
I suspect it is your [type of payment]. Did they choose a text selection of
the word "check" as your statement implies, or is this a check box whose
value is True or False? If so, your statement should say:
If [type of payment] = True Then


Amelia said:
This did not work. It gives me a run-time error '13' : type mismatch

I have the field [check number] properties set to visible=no. Should I
have
it left like this?

I am pulling the information from a query, so should I do the code in the
query and not in the form?



M Skabialka said:
IIF is used in a query, you need IF with one "I"

Private Sub Type_of_Payment_AfterUpdate()
If [type of payment] = "check" Then
Me![check number].Visible = True
Else
Me![check number].Visible = False
End If
End Sub

I have a checkbox that has the option to choose [type of payment] if the
person chooses "check" as the type of payment I want [check number]
visible
to the user and also required to be filled in. I have tried different
things,
but I am new to writing these in Visual Basic.

I am going into the form, design view, go to properties for [type of
payment] and going to after update. I want to create an event
procedure.
Any
one have an idea of what code to use?

I have tried:

Private Sub Type_of_Payment_AfterUpdate()
IIf ([type of payment] = "check" then me![check number].Visible=true)
else me![check number].Visible=false end IIF

End Sub
 
M

Mrs. Ugh

Maybe try: If Me![type of payment] = "check"...

Amelia said:
It is a combo box with the options mentioned before. When I go to the data,
my row source is what I have listed in my previous post. So this is why I am
not sure why it is not working.

M Skabialka said:
Which line gives you the error?
When you get the error, press CTRL-Break to get into the code. The line
highlighted in yellow is where the error is occuring.
I suspect it is your [type of payment]. Did they choose a text selection of
the word "check" as your statement implies, or is this a check box whose
value is True or False? If so, your statement should say:
If [type of payment] = True Then


Amelia said:
This did not work. It gives me a run-time error '13' : type mismatch

I have the field [check number] properties set to visible=no. Should I
have
it left like this?

I am pulling the information from a query, so should I do the code in the
query and not in the form?



:

IIF is used in a query, you need IF with one "I"

Private Sub Type_of_Payment_AfterUpdate()
If [type of payment] = "check" Then
Me![check number].Visible = True
Else
Me![check number].Visible = False
End If
End Sub

I have a checkbox that has the option to choose [type of payment] if the
person chooses "check" as the type of payment I want [check number]
visible
to the user and also required to be filled in. I have tried different
things,
but I am new to writing these in Visual Basic.

I am going into the form, design view, go to properties for [type of
payment] and going to after update. I want to create an event
procedure.
Any
one have an idea of what code to use?

I have tried:

Private Sub Type_of_Payment_AfterUpdate()
IIf ([type of payment] = "check" then me![check number].Visible=true)
else me![check number].Visible=false end IIF

End Sub
 
M

M Skabialka

So far you have defined the same control as a check box, an option and a
combo.
Please tell us the type of control it is, and the exact row source so we can
help you better. Is it a list of items, a query.... ???
Mich

Amelia said:
It is a combo box with the options mentioned before. When I go to the
data,
my row source is what I have listed in my previous post. So this is why I
am
not sure why it is not working.

M Skabialka said:
Which line gives you the error?
When you get the error, press CTRL-Break to get into the code. The line
highlighted in yellow is where the error is occuring.
I suspect it is your [type of payment]. Did they choose a text selection
of
the word "check" as your statement implies, or is this a check box whose
value is True or False? If so, your statement should say:
If [type of payment] = True Then


Amelia said:
This did not work. It gives me a run-time error '13' : type mismatch

I have the field [check number] properties set to visible=no. Should I
have
it left like this?

I am pulling the information from a query, so should I do the code in
the
query and not in the form?



:

IIF is used in a query, you need IF with one "I"

Private Sub Type_of_Payment_AfterUpdate()
If [type of payment] = "check" Then
Me![check number].Visible = True
Else
Me![check number].Visible = False
End If
End Sub

I have a checkbox that has the option to choose [type of payment] if
the
person chooses "check" as the type of payment I want [check number]
visible
to the user and also required to be filled in. I have tried
different
things,
but I am new to writing these in Visual Basic.

I am going into the form, design view, go to properties for [type of
payment] and going to after update. I want to create an event
procedure.
Any
one have an idea of what code to use?

I have tried:

Private Sub Type_of_Payment_AfterUpdate()
IIf ([type of payment] = "check" then me![check
number].Visible=true)
else me![check number].Visible=false end IIF

End Sub
 
A

Amelia

It is a combo box. Sorry for the confusion. I am new to Access. I was
thinking check box since it has checkboxes to mark.

The row source is: "Cash";"Check";"Credit Card";"Money Order";"Other"

I am in a form and when the person fills out this form and selects [type of
payment] as "check" I want [check number] to show up for them to fill out
which will then be required.

I hope this explains it better. Thanks for the help and ideas!
Amy
M Skabialka said:
So far you have defined the same control as a check box, an option and a
combo.
Please tell us the type of control it is, and the exact row source so we can
help you better. Is it a list of items, a query.... ???
Mich

Amelia said:
It is a combo box with the options mentioned before. When I go to the
data,
my row source is what I have listed in my previous post. So this is why I
am
not sure why it is not working.

M Skabialka said:
Which line gives you the error?
When you get the error, press CTRL-Break to get into the code. The line
highlighted in yellow is where the error is occuring.
I suspect it is your [type of payment]. Did they choose a text selection
of
the word "check" as your statement implies, or is this a check box whose
value is True or False? If so, your statement should say:
If [type of payment] = True Then


This did not work. It gives me a run-time error '13' : type mismatch

I have the field [check number] properties set to visible=no. Should I
have
it left like this?

I am pulling the information from a query, so should I do the code in
the
query and not in the form?



:

IIF is used in a query, you need IF with one "I"

Private Sub Type_of_Payment_AfterUpdate()
If [type of payment] = "check" Then
Me![check number].Visible = True
Else
Me![check number].Visible = False
End If
End Sub

I have a checkbox that has the option to choose [type of payment] if
the
person chooses "check" as the type of payment I want [check number]
visible
to the user and also required to be filled in. I have tried
different
things,
but I am new to writing these in Visual Basic.

I am going into the form, design view, go to properties for [type of
payment] and going to after update. I want to create an event
procedure.
Any
one have an idea of what code to use?

I have tried:

Private Sub Type_of_Payment_AfterUpdate()
IIf ([type of payment] = "check" then me![check
number].Visible=true)
else me![check number].Visible=false end IIF

End Sub
 
M

M Skabialka

Have you debugged your project? In the code window, Debug - compile. Do
you get any errors?

When you get the run-time error '13' : type mismatch error, press CTRL-Break
to get into the code. The line
highlighted in yellow is where the error is occuring. If that doesn't work,
try adding a line that says Stop as shown - this will break you into the
code and you can press F8 to go through the code line by line until you get
the error. Remove the Stop line when you are finished testing. The same
thing can be done by highlighting a line and selecting Debug - Toggle
Breakpoint.

Which line is giving you the error?

Private Sub Type_of_Payment_AfterUpdate()
Stop
If Me![type of payment] = "Check" Then
Me![check number].Visible = True
Else
Me![check number].Visible = False
End If
End Sub

Amelia said:
It is a combo box. Sorry for the confusion. I am new to Access. I was
thinking check box since it has checkboxes to mark.

The row source is: "Cash";"Check";"Credit Card";"Money Order";"Other"

I am in a form and when the person fills out this form and selects [type
of
payment] as "check" I want [check number] to show up for them to fill out
which will then be required.

I hope this explains it better. Thanks for the help and ideas!
Amy
M Skabialka said:
So far you have defined the same control as a check box, an option and a
combo.
Please tell us the type of control it is, and the exact row source so we
can
help you better. Is it a list of items, a query.... ???
Mich

Amelia said:
It is a combo box with the options mentioned before. When I go to the
data,
my row source is what I have listed in my previous post. So this is why
I
am
not sure why it is not working.

:

Which line gives you the error?
When you get the error, press CTRL-Break to get into the code. The
line
highlighted in yellow is where the error is occuring.
I suspect it is your [type of payment]. Did they choose a text
selection
of
the word "check" as your statement implies, or is this a check box
whose
value is True or False? If so, your statement should say:
If [type of payment] = True Then


This did not work. It gives me a run-time error '13' : type mismatch

I have the field [check number] properties set to visible=no. Should
I
have
it left like this?

I am pulling the information from a query, so should I do the code
in
the
query and not in the form?



:

IIF is used in a query, you need IF with one "I"

Private Sub Type_of_Payment_AfterUpdate()
If [type of payment] = "check" Then
Me![check number].Visible = True
Else
Me![check number].Visible = False
End If
End Sub

I have a checkbox that has the option to choose [type of payment]
if
the
person chooses "check" as the type of payment I want [check
number]
visible
to the user and also required to be filled in. I have tried
different
things,
but I am new to writing these in Visual Basic.

I am going into the form, design view, go to properties for [type
of
payment] and going to after update. I want to create an event
procedure.
Any
one have an idea of what code to use?

I have tried:

Private Sub Type_of_Payment_AfterUpdate()
IIf ([type of payment] = "check" then me![check
number].Visible=true)
else me![check number].Visible=false end IIF

End Sub
 

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