IF THEN

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

Guest

I have a combo box [Combo103] where I will make a selection. If that
selection is "7", then I want my text box [armrest fabric] to be ".25". If
it's not "7" then I want it to display "0"

i not very educated at Visual Basic Code and I assume that I'll have to use
it here. If it's a simple code could someone please just write it out for me.
I can never figure it out when people try to just explain how to do it.

Thanks in advance,
Travis
 
Hi Travis,

In the After Update event of Combo 103, put the following:

If Me.[Combo 103] = 7 Then
Me.[armrest fabric] = 0.25
Else Me.[armrest fabric] = 0
End If

(I'm assuming you gave the actual name of the combo and text boxes)
 
That works great,
My next problem is what if I want it to display ".25" when [combo103]
display "7","18", or "19"

SusanV said:
Hi Travis,

In the After Update event of Combo 103, put the following:

If Me.[Combo 103] = 7 Then
Me.[armrest fabric] = 0.25
Else Me.[armrest fabric] = 0
End If

(I'm assuming you gave the actual name of the combo and text boxes)
--
hth,
SusanV



Tdahlman said:
I have a combo box [Combo103] where I will make a selection. If that
selection is "7", then I want my text box [armrest fabric] to be ".25". If
it's not "7" then I want it to display "0"

i not very educated at Visual Basic Code and I assume that I'll have to
use
it here. If it's a simple code could someone please just write it out for
me.
I can never figure it out when people try to just explain how to do it.

Thanks in advance,
Travis
 
If you have a bunch of things which will bring the same result, you can
group them in the If statement using OR:

If Me.[Combo 103] = 7 OR Me.[Combo 103] = 18 OR Me.[Combo 103] = 19 Then
Me.[armrest fabric] = 0.25
Else Me.[armrest fabric] = 0
End If


For a large number of option/result combos, you would want to use a SELECT
CASE statement, as it's simpler to follow and modify if need be:

SELECT CASE Me.[Combo 103]
Case 7
Me.[armrest fabric] = 0.25

Case 8
Me.[armrest fabric] = 0.50
Case 9
Me.[armrest fabric] = 0.75
Case Else Me.[armrest fabric] = 0
END SELECT

;-)



Tdahlman said:
That works great,
My next problem is what if I want it to display ".25" when [combo103]
display "7","18", or "19"

SusanV said:
Hi Travis,

In the After Update event of Combo 103, put the following:

If Me.[Combo 103] = 7 Then
Me.[armrest fabric] = 0.25
Else Me.[armrest fabric] = 0
End If

(I'm assuming you gave the actual name of the combo and text boxes)
--
hth,
SusanV



Tdahlman said:
I have a combo box [Combo103] where I will make a selection. If that
selection is "7", then I want my text box [armrest fabric] to be ".25".
If
it's not "7" then I want it to display "0"

i not very educated at Visual Basic Code and I assume that I'll have to
use
it here. If it's a simple code could someone please just write it out
for
me.
I can never figure it out when people try to just explain how to do it.

Thanks in advance,
Travis
 
Thank you very much. This is very helpful.
Travis

SusanV said:
If you have a bunch of things which will bring the same result, you can
group them in the If statement using OR:

If Me.[Combo 103] = 7 OR Me.[Combo 103] = 18 OR Me.[Combo 103] = 19 Then
Me.[armrest fabric] = 0.25
Else Me.[armrest fabric] = 0
End If


For a large number of option/result combos, you would want to use a SELECT
CASE statement, as it's simpler to follow and modify if need be:

SELECT CASE Me.[Combo 103]
Case 7
Me.[armrest fabric] = 0.25

Case 8
Me.[armrest fabric] = 0.50
Case 9
Me.[armrest fabric] = 0.75
Case Else Me.[armrest fabric] = 0
END SELECT

;-)



Tdahlman said:
That works great,
My next problem is what if I want it to display ".25" when [combo103]
display "7","18", or "19"

SusanV said:
Hi Travis,

In the After Update event of Combo 103, put the following:

If Me.[Combo 103] = 7 Then
Me.[armrest fabric] = 0.25
Else Me.[armrest fabric] = 0
End If

(I'm assuming you gave the actual name of the combo and text boxes)
--
hth,
SusanV



I have a combo box [Combo103] where I will make a selection. If that
selection is "7", then I want my text box [armrest fabric] to be ".25".
If
it's not "7" then I want it to display "0"

i not very educated at Visual Basic Code and I assume that I'll have to
use
it here. If it's a simple code could someone please just write it out
for
me.
I can never figure it out when people try to just explain how to do it.

Thanks in advance,
Travis
 
Glad to help any time!

Tdahlman said:
Thank you very much. This is very helpful.
Travis

SusanV said:
If you have a bunch of things which will bring the same result, you can
group them in the If statement using OR:

If Me.[Combo 103] = 7 OR Me.[Combo 103] = 18 OR Me.[Combo 103] = 19 Then
Me.[armrest fabric] = 0.25
Else Me.[armrest fabric] = 0
End If


For a large number of option/result combos, you would want to use a
SELECT
CASE statement, as it's simpler to follow and modify if need be:

SELECT CASE Me.[Combo 103]
Case 7
Me.[armrest fabric] = 0.25

Case 8
Me.[armrest fabric] = 0.50
Case 9
Me.[armrest fabric] = 0.75
Case Else Me.[armrest fabric] = 0
END SELECT

;-)



Tdahlman said:
That works great,
My next problem is what if I want it to display ".25" when [combo103]
display "7","18", or "19"

:

Hi Travis,

In the After Update event of Combo 103, put the following:

If Me.[Combo 103] = 7 Then
Me.[armrest fabric] = 0.25
Else Me.[armrest fabric] = 0
End If

(I'm assuming you gave the actual name of the combo and text boxes)
--
hth,
SusanV



I have a combo box [Combo103] where I will make a selection. If that
selection is "7", then I want my text box [armrest fabric] to be
".25".
If
it's not "7" then I want it to display "0"

i not very educated at Visual Basic Code and I assume that I'll have
to
use
it here. If it's a simple code could someone please just write it
out
for
me.
I can never figure it out when people try to just explain how to do
it.

Thanks in advance,
Travis
 
While Susan's shown you one way, you may need a more flexible approach if
this is a growing need.

What's the row source for your combo box? If it's a table, can you add an
additional field to that table, indicating what the value that's supposed to
be put into [armrest fabric]? In that way, you could include it as an
additional column in the combo box (it needn't be visible), and then put
code in the AfterUpdate event of the combo box to take the value from the
currently selected row and put it into the text box.

Assuming you've got the value as the 2nd column in the combo box, you'd use

Private Sub Combo103_AfterUpdate()

Me.[armrest fabric] = Me.Combo103.Column(1)

End Sub

The Column collection starts numbering at 0, so that the 2nd column is
referred to as 1, as above.
 
Nice Doug! Hadn't thought of this - but can think of many uses!

SusanV

Douglas J. Steele said:
While Susan's shown you one way, you may need a more flexible approach if
this is a growing need.

What's the row source for your combo box? If it's a table, can you add an
additional field to that table, indicating what the value that's supposed
to be put into [armrest fabric]? In that way, you could include it as an
additional column in the combo box (it needn't be visible), and then put
code in the AfterUpdate event of the combo box to take the value from the
currently selected row and put it into the text box.

Assuming you've got the value as the 2nd column in the combo box, you'd
use

Private Sub Combo103_AfterUpdate()

Me.[armrest fabric] = Me.Combo103.Column(1)

End Sub

The Column collection starts numbering at 0, so that the 2nd column is
referred to as 1, as above.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Tdahlman said:
I have a combo box [Combo103] where I will make a selection. If that
selection is "7", then I want my text box [armrest fabric] to be ".25".
If
it's not "7" then I want it to display "0"

i not very educated at Visual Basic Code and I assume that I'll have to
use
it here. If it's a simple code could someone please just write it out for
me.
I can never figure it out when people try to just explain how to do it.

Thanks in advance,
Travis
 

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

Back
Top