If Statement

  • Thread starter Thread starter James
  • Start date Start date
J

James

I have this combo box 'cboComboBox' on my form
I would like to make it so the default value is an IF
statement that is dependant on another text
box 'txtTextBox'.
For example if the text box = "product 1" then price in
the combo box = "price 1" or if the text box = "product
2" then price in the combo box = "price 2". Or if the
text box is not "product 1" or "Product 2" then don't
change the value in combo box (can't use Null because I
don't want to lose the vale if there is already a
something in the combo box there).
I am bit new to this but I think this is how the code
might look
? Can it be done or can anyone suggest another way to
achieve the same results. Thanks

On Forms Current event
IF txtTextBox = "Prouct 1" Then
cboComboBox = "Price 1"

Else If txtTextBox = "Product 2" Then
cboComboBox = "Price 2"

Else If txtTextBox <> "Porduct 2" Or "Porduct 1" Then
cboComboBox = (Don't change value ????)

End If
End Sub
 
Use the followeing code

On Forms Current event
IF txtTextBox = "Prouct 1" Then
cboComboBox = "Price 1"
Else If txtTextBox = "Product 2" Then
cboComboBox = "Price 2"
End If

By using the above code only if one of th "If"statements is true the value
in the cbo will be changed
 
thanks

-----Original Message-----
Use the followeing code

On Forms Current event
IF txtTextBox = "Prouct 1" Then
cboComboBox = "Price 1"
Else If txtTextBox = "Product 2" Then
cboComboBox = "Price 2"
End If

By using the above code only if one of th "If"statements is true the value
in the cbo will be changed




.
 
Back
Top