populate a text field based on a combo box

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

Guest

hello
I would like to set a value to a text field depending on the value of a
combo box.
for example the combo box has category 1,2,3 and 4.
Now i would like the fee value to display 10 if category 1 is selected
20 if category 2 is selected. so on and so forth.

Your help will be greatly appreciated
 
Hi fifi
Try this stages
1. To the RowSource of the ComboBox add the "fee" field.
Select category , fee From TableName

2. On the after update event of the combo box, write the code to assign the
fee value to the text box
Me.[TextBoxName] = Me.[ComboName].Column(1)

Note: the column number start with 0

3. If the fee field is to be displayed only, and the user can't update it,
you can set the control source of the text box to
=[ComboName].Column(1)

So you wont need the after update event of the combo from stage 2
 
Thanks for your response but the issue is I don't want the values to be
equal, I want something like if category 1 is selected from the possible 4,
then the fee =20
so on and so forth.


Ofer Cohen said:
Hi fifi
Try this stages
1. To the RowSource of the ComboBox add the "fee" field.
Select category , fee From TableName

2. On the after update event of the combo box, write the code to assign the
fee value to the text box
Me.[TextBoxName] = Me.[ComboName].Column(1)

Note: the column number start with 0

3. If the fee field is to be displayed only, and the user can't update it,
you can set the control source of the text box to
=[ComboName].Column(1)

So you wont need the after update event of the combo from stage 2

--
Good Luck
BS"D


fifi said:
hello
I would like to set a value to a text field depending on the value of a
combo box.
for example the combo box has category 1,2,3 and 4.
Now i would like the fee value to display 10 if category 1 is selected
20 if category 2 is selected. so on and so forth.

Your help will be greatly appreciated
 
You can hard code the selection, something like
Select case Me.ComboName
Case 1
Me.fee = 20
Case 2
Me.fee = 30
Case 3
Me.fee = ...
Case 4
Me.fee = ...
End Select

but I wouldn't use this method, I would add another field to the category
table that contain the fee for each category, and implement the method I
posted before.
That way if the fee changes you don't need to change the code, just change
the value of the fee in the table
--
Good Luck
BS"D


fifi said:
Thanks for your response but the issue is I don't want the values to be
equal, I want something like if category 1 is selected from the possible 4,
then the fee =20
so on and so forth.


Ofer Cohen said:
Hi fifi
Try this stages
1. To the RowSource of the ComboBox add the "fee" field.
Select category , fee From TableName

2. On the after update event of the combo box, write the code to assign the
fee value to the text box
Me.[TextBoxName] = Me.[ComboName].Column(1)

Note: the column number start with 0

3. If the fee field is to be displayed only, and the user can't update it,
you can set the control source of the text box to
=[ComboName].Column(1)

So you wont need the after update event of the combo from stage 2

--
Good Luck
BS"D


fifi said:
hello
I would like to set a value to a text field depending on the value of a
combo box.
for example the combo box has category 1,2,3 and 4.
Now i would like the fee value to display 10 if category 1 is selected
20 if category 2 is selected. so on and so forth.

Your help will be greatly appreciated
 
What if i want to conditions to be met before setting up the fee. Like if
category is 1 and paidby = client then fee =20
and if category =1 and paidby=company then fee=30
I appreciate your help

Ofer Cohen said:
You can hard code the selection, something like
Select case Me.ComboName
Case 1
Me.fee = 20
Case 2
Me.fee = 30
Case 3
Me.fee = ...
Case 4
Me.fee = ...
End Select

but I wouldn't use this method, I would add another field to the category
table that contain the fee for each category, and implement the method I
posted before.
That way if the fee changes you don't need to change the code, just change
the value of the fee in the table
--
Good Luck
BS"D


fifi said:
Thanks for your response but the issue is I don't want the values to be
equal, I want something like if category 1 is selected from the possible 4,
then the fee =20
so on and so forth.


Ofer Cohen said:
Hi fifi
Try this stages
1. To the RowSource of the ComboBox add the "fee" field.
Select category , fee From TableName

2. On the after update event of the combo box, write the code to assign the
fee value to the text box
Me.[TextBoxName] = Me.[ComboName].Column(1)

Note: the column number start with 0

3. If the fee field is to be displayed only, and the user can't update it,
you can set the control source of the text box to
=[ComboName].Column(1)

So you wont need the after update event of the combo from stage 2

--
Good Luck
BS"D


:

hello
I would like to set a value to a text field depending on the value of a
combo box.
for example the combo box has category 1,2,3 and 4.
Now i would like the fee value to display 10 if category 1 is selected
20 if category 2 is selected. so on and so forth.

Your help will be greatly appreciated
 
You can use if

If category = 1 and paidby = "client" then
fee =20
Else
if category =1 and paidby= "company" then
fee=30
End If
End If

Or istead of having alot of if and Else, use seperate If and exit Sub within
each one of them

If category = 1 and paidby = "client" then
fee =20
Exit Sub
End If
if category =1 and paidby= "company" then
fee=30
Exit Sub
End If

--
Good Luck
BS"D


fifi said:
What if i want to conditions to be met before setting up the fee. Like if
category is 1 and paidby = client then fee =20
and if category =1 and paidby=company then fee=30
I appreciate your help

Ofer Cohen said:
You can hard code the selection, something like
Select case Me.ComboName
Case 1
Me.fee = 20
Case 2
Me.fee = 30
Case 3
Me.fee = ...
Case 4
Me.fee = ...
End Select

but I wouldn't use this method, I would add another field to the category
table that contain the fee for each category, and implement the method I
posted before.
That way if the fee changes you don't need to change the code, just change
the value of the fee in the table
--
Good Luck
BS"D


fifi said:
Thanks for your response but the issue is I don't want the values to be
equal, I want something like if category 1 is selected from the possible 4,
then the fee =20
so on and so forth.


:

Hi fifi
Try this stages
1. To the RowSource of the ComboBox add the "fee" field.
Select category , fee From TableName

2. On the after update event of the combo box, write the code to assign the
fee value to the text box
Me.[TextBoxName] = Me.[ComboName].Column(1)

Note: the column number start with 0

3. If the fee field is to be displayed only, and the user can't update it,
you can set the control source of the text box to
=[ComboName].Column(1)

So you wont need the after update event of the combo from stage 2

--
Good Luck
BS"D


:

hello
I would like to set a value to a text field depending on the value of a
combo box.
for example the combo box has category 1,2,3 and 4.
Now i would like the fee value to display 10 if category 1 is selected
20 if category 2 is selected. so on and so forth.

Your help will be greatly appreciated
 
the only problem i have is that category and paidby are not text field, they
are combo boxes.

Ofer Cohen said:
You can use if

If category = 1 and paidby = "client" then
fee =20
Else
if category =1 and paidby= "company" then
fee=30
End If
End If

Or istead of having alot of if and Else, use seperate If and exit Sub within
each one of them

If category = 1 and paidby = "client" then
fee =20
Exit Sub
End If
if category =1 and paidby= "company" then
fee=30
Exit Sub
End If

--
Good Luck
BS"D


fifi said:
What if i want to conditions to be met before setting up the fee. Like if
category is 1 and paidby = client then fee =20
and if category =1 and paidby=company then fee=30
I appreciate your help

Ofer Cohen said:
You can hard code the selection, something like
Select case Me.ComboName
Case 1
Me.fee = 20
Case 2
Me.fee = 30
Case 3
Me.fee = ...
Case 4
Me.fee = ...
End Select

but I wouldn't use this method, I would add another field to the category
table that contain the fee for each category, and implement the method I
posted before.
That way if the fee changes you don't need to change the code, just change
the value of the fee in the table
--
Good Luck
BS"D


:

Thanks for your response but the issue is I don't want the values to be
equal, I want something like if category 1 is selected from the possible 4,
then the fee =20
so on and so forth.


:

Hi fifi
Try this stages
1. To the RowSource of the ComboBox add the "fee" field.
Select category , fee From TableName

2. On the after update event of the combo box, write the code to assign the
fee value to the text box
Me.[TextBoxName] = Me.[ComboName].Column(1)

Note: the column number start with 0

3. If the fee field is to be displayed only, and the user can't update it,
you can set the control source of the text box to
=[ComboName].Column(1)

So you wont need the after update event of the combo from stage 2

--
Good Luck
BS"D


:

hello
I would like to set a value to a text field depending on the value of a
combo box.
for example the combo box has category 1,2,3 and 4.
Now i would like the fee value to display 10 if category 1 is selected
20 if category 2 is selected. so on and so forth.

Your help will be greatly appreciated
 
I apologize for the headaches. The form is for billing existing customers.
So I will always know who pays. Like I said I have a combo box for category
and another one for paidby, now I would like the fee to be determined
depending on the conditions.
Like if cat=1 and paidby=client then fee=20. Let's keep in mind that the
user is not typing in the cat or paid. They just have to select from a drop
down


fifi said:
the only problem i have is that category and paidby are not text field, they
are combo boxes.

Ofer Cohen said:
You can use if

If category = 1 and paidby = "client" then
fee =20
Else
if category =1 and paidby= "company" then
fee=30
End If
End If

Or istead of having alot of if and Else, use seperate If and exit Sub within
each one of them

If category = 1 and paidby = "client" then
fee =20
Exit Sub
End If
if category =1 and paidby= "company" then
fee=30
Exit Sub
End If

--
Good Luck
BS"D


fifi said:
What if i want to conditions to be met before setting up the fee. Like if
category is 1 and paidby = client then fee =20
and if category =1 and paidby=company then fee=30
I appreciate your help

:

You can hard code the selection, something like
Select case Me.ComboName
Case 1
Me.fee = 20
Case 2
Me.fee = 30
Case 3
Me.fee = ...
Case 4
Me.fee = ...
End Select

but I wouldn't use this method, I would add another field to the category
table that contain the fee for each category, and implement the method I
posted before.
That way if the fee changes you don't need to change the code, just change
the value of the fee in the table
--
Good Luck
BS"D


:

Thanks for your response but the issue is I don't want the values to be
equal, I want something like if category 1 is selected from the possible 4,
then the fee =20
so on and so forth.


:

Hi fifi
Try this stages
1. To the RowSource of the ComboBox add the "fee" field.
Select category , fee From TableName

2. On the after update event of the combo box, write the code to assign the
fee value to the text box
Me.[TextBoxName] = Me.[ComboName].Column(1)

Note: the column number start with 0

3. If the fee field is to be displayed only, and the user can't update it,
you can set the control source of the text box to
=[ComboName].Column(1)

So you wont need the after update event of the combo from stage 2

--
Good Luck
BS"D


:

hello
I would like to set a value to a text field depending on the value of a
combo box.
for example the combo box has category 1,2,3 and 4.
Now i would like the fee value to display 10 if category 1 is selected
20 if category 2 is selected. so on and so forth.

Your help will be greatly appreciated
 
I'm not sure what you are asking for.
In the code there shouldn't be any different between text box or combo

If Me.[categoryComboName] = 1 and Me.[paidbyComboName] = 2 then
me.[fee text box name] =20
Exit Sub
End If


--
Good Luck
BS"D


fifi said:
I apologize for the headaches. The form is for billing existing customers.
So I will always know who pays. Like I said I have a combo box for category
and another one for paidby, now I would like the fee to be determined
depending on the conditions.
Like if cat=1 and paidby=client then fee=20. Let's keep in mind that the
user is not typing in the cat or paid. They just have to select from a drop
down


fifi said:
the only problem i have is that category and paidby are not text field, they
are combo boxes.

Ofer Cohen said:
You can use if

If category = 1 and paidby = "client" then
fee =20
Else
if category =1 and paidby= "company" then
fee=30
End If
End If

Or istead of having alot of if and Else, use seperate If and exit Sub within
each one of them

If category = 1 and paidby = "client" then
fee =20
Exit Sub
End If
if category =1 and paidby= "company" then
fee=30
Exit Sub
End If

--
Good Luck
BS"D


:

What if i want to conditions to be met before setting up the fee. Like if
category is 1 and paidby = client then fee =20
and if category =1 and paidby=company then fee=30
I appreciate your help

:

You can hard code the selection, something like
Select case Me.ComboName
Case 1
Me.fee = 20
Case 2
Me.fee = 30
Case 3
Me.fee = ...
Case 4
Me.fee = ...
End Select

but I wouldn't use this method, I would add another field to the category
table that contain the fee for each category, and implement the method I
posted before.
That way if the fee changes you don't need to change the code, just change
the value of the fee in the table
--
Good Luck
BS"D


:

Thanks for your response but the issue is I don't want the values to be
equal, I want something like if category 1 is selected from the possible 4,
then the fee =20
so on and so forth.


:

Hi fifi
Try this stages
1. To the RowSource of the ComboBox add the "fee" field.
Select category , fee From TableName

2. On the after update event of the combo box, write the code to assign the
fee value to the text box
Me.[TextBoxName] = Me.[ComboName].Column(1)

Note: the column number start with 0

3. If the fee field is to be displayed only, and the user can't update it,
you can set the control source of the text box to
=[ComboName].Column(1)

So you wont need the after update event of the combo from stage 2

--
Good Luck
BS"D


:

hello
I would like to set a value to a text field depending on the value of a
combo box.
for example the combo box has category 1,2,3 and 4.
Now i would like the fee value to display 10 if category 1 is selected
20 if category 2 is selected. so on and so forth.

Your help will be greatly appreciated
 
It is different since the code works fine with a text box, but it doesn't
with a combo box. I am guess

Ofer Cohen said:
I'm not sure what you are asking for.
In the code there shouldn't be any different between text box or combo

If Me.[categoryComboName] = 1 and Me.[paidbyComboName] = 2 then
me.[fee text box name] =20
Exit Sub
End If


--
Good Luck
BS"D


fifi said:
I apologize for the headaches. The form is for billing existing customers.
So I will always know who pays. Like I said I have a combo box for category
and another one for paidby, now I would like the fee to be determined
depending on the conditions.
Like if cat=1 and paidby=client then fee=20. Let's keep in mind that the
user is not typing in the cat or paid. They just have to select from a drop
down


fifi said:
the only problem i have is that category and paidby are not text field, they
are combo boxes.

:

You can use if

If category = 1 and paidby = "client" then
fee =20
Else
if category =1 and paidby= "company" then
fee=30
End If
End If

Or istead of having alot of if and Else, use seperate If and exit Sub within
each one of them

If category = 1 and paidby = "client" then
fee =20
Exit Sub
End If
if category =1 and paidby= "company" then
fee=30
Exit Sub
End If

--
Good Luck
BS"D


:

What if i want to conditions to be met before setting up the fee. Like if
category is 1 and paidby = client then fee =20
and if category =1 and paidby=company then fee=30
I appreciate your help

:

You can hard code the selection, something like
Select case Me.ComboName
Case 1
Me.fee = 20
Case 2
Me.fee = 30
Case 3
Me.fee = ...
Case 4
Me.fee = ...
End Select

but I wouldn't use this method, I would add another field to the category
table that contain the fee for each category, and implement the method I
posted before.
That way if the fee changes you don't need to change the code, just change
the value of the fee in the table
--
Good Luck
BS"D


:

Thanks for your response but the issue is I don't want the values to be
equal, I want something like if category 1 is selected from the possible 4,
then the fee =20
so on and so forth.


:

Hi fifi
Try this stages
1. To the RowSource of the ComboBox add the "fee" field.
Select category , fee From TableName

2. On the after update event of the combo box, write the code to assign the
fee value to the text box
Me.[TextBoxName] = Me.[ComboName].Column(1)

Note: the column number start with 0

3. If the fee field is to be displayed only, and the user can't update it,
you can set the control source of the text box to
=[ComboName].Column(1)

So you wont need the after update event of the combo from stage 2

--
Good Luck
BS"D


:

hello
I would like to set a value to a text field depending on the value of a
combo box.
for example the combo box has category 1,2,3 and 4.
Now i would like the fee value to display 10 if category 1 is selected
20 if category 2 is selected. so on and so forth.

Your help will be greatly appreciated
 
What is the order of the columns in the RowSource of the combo?

If the field you are comparing located on the second column, then you need
to change If statement to

If Me.[categoryComboName].column(1) = 1 and Me.[paidbyComboName].column(1) =
2 then
me.[fee text box name] =20
Exit Sub
End If

Note: the column number start from 0, and if not specified it will take the
value from the first column


--
Good Luck
BS"D


fifi said:
It is different since the code works fine with a text box, but it doesn't
with a combo box. I am guess

Ofer Cohen said:
I'm not sure what you are asking for.
In the code there shouldn't be any different between text box or combo

If Me.[categoryComboName] = 1 and Me.[paidbyComboName] = 2 then
me.[fee text box name] =20
Exit Sub
End If


--
Good Luck
BS"D


fifi said:
I apologize for the headaches. The form is for billing existing customers.
So I will always know who pays. Like I said I have a combo box for category
and another one for paidby, now I would like the fee to be determined
depending on the conditions.
Like if cat=1 and paidby=client then fee=20. Let's keep in mind that the
user is not typing in the cat or paid. They just have to select from a drop
down


:

the only problem i have is that category and paidby are not text field, they
are combo boxes.

:

You can use if

If category = 1 and paidby = "client" then
fee =20
Else
if category =1 and paidby= "company" then
fee=30
End If
End If

Or istead of having alot of if and Else, use seperate If and exit Sub within
each one of them

If category = 1 and paidby = "client" then
fee =20
Exit Sub
End If
if category =1 and paidby= "company" then
fee=30
Exit Sub
End If

--
Good Luck
BS"D


:

What if i want to conditions to be met before setting up the fee. Like if
category is 1 and paidby = client then fee =20
and if category =1 and paidby=company then fee=30
I appreciate your help

:

You can hard code the selection, something like
Select case Me.ComboName
Case 1
Me.fee = 20
Case 2
Me.fee = 30
Case 3
Me.fee = ...
Case 4
Me.fee = ...
End Select

but I wouldn't use this method, I would add another field to the category
table that contain the fee for each category, and implement the method I
posted before.
That way if the fee changes you don't need to change the code, just change
the value of the fee in the table
--
Good Luck
BS"D


:

Thanks for your response but the issue is I don't want the values to be
equal, I want something like if category 1 is selected from the possible 4,
then the fee =20
so on and so forth.


:

Hi fifi
Try this stages
1. To the RowSource of the ComboBox add the "fee" field.
Select category , fee From TableName

2. On the after update event of the combo box, write the code to assign the
fee value to the text box
Me.[TextBoxName] = Me.[ComboName].Column(1)

Note: the column number start with 0

3. If the fee field is to be displayed only, and the user can't update it,
you can set the control source of the text box to
=[ComboName].Column(1)

So you wont need the after update event of the combo from stage 2

--
Good Luck
BS"D


:

hello
I would like to set a value to a text field depending on the value of a
combo box.
for example the combo box has category 1,2,3 and 4.
Now i would like the fee value to display 10 if category 1 is selected
20 if category 2 is selected. so on and so forth.

Your help will be greatly appreciated
 
the category combo,1st row is 1,2nd is 2, then 3 , then 4.
the paidby combo, it is company, client, TBD then other.
Again I want something like if category =1 (or is the 1rst row is selected)
and paidby=client ( or 2nd row is selected) then fee= x dollars.
if category =3 (or is the 3rd row is selected) and paidby=client ( or 2nd
row is selected) then fee= y dollars

Thanks again

Ofer Cohen said:
What is the order of the columns in the RowSource of the combo?

If the field you are comparing located on the second column, then you need
to change If statement to

If Me.[categoryComboName].column(1) = 1 and Me.[paidbyComboName].column(1) =
2 then
me.[fee text box name] =20
Exit Sub
End If

Note: the column number start from 0, and if not specified it will take the
value from the first column


--
Good Luck
BS"D


fifi said:
It is different since the code works fine with a text box, but it doesn't
with a combo box. I am guess

Ofer Cohen said:
I'm not sure what you are asking for.
In the code there shouldn't be any different between text box or combo

If Me.[categoryComboName] = 1 and Me.[paidbyComboName] = 2 then
me.[fee text box name] =20
Exit Sub
End If


--
Good Luck
BS"D


:

I apologize for the headaches. The form is for billing existing customers.
So I will always know who pays. Like I said I have a combo box for category
and another one for paidby, now I would like the fee to be determined
depending on the conditions.
Like if cat=1 and paidby=client then fee=20. Let's keep in mind that the
user is not typing in the cat or paid. They just have to select from a drop
down


:

the only problem i have is that category and paidby are not text field, they
are combo boxes.

:

You can use if

If category = 1 and paidby = "client" then
fee =20
Else
if category =1 and paidby= "company" then
fee=30
End If
End If

Or istead of having alot of if and Else, use seperate If and exit Sub within
each one of them

If category = 1 and paidby = "client" then
fee =20
Exit Sub
End If
if category =1 and paidby= "company" then
fee=30
Exit Sub
End If

--
Good Luck
BS"D


:

What if i want to conditions to be met before setting up the fee. Like if
category is 1 and paidby = client then fee =20
and if category =1 and paidby=company then fee=30
I appreciate your help

:

You can hard code the selection, something like
Select case Me.ComboName
Case 1
Me.fee = 20
Case 2
Me.fee = 30
Case 3
Me.fee = ...
Case 4
Me.fee = ...
End Select

but I wouldn't use this method, I would add another field to the category
table that contain the fee for each category, and implement the method I
posted before.
That way if the fee changes you don't need to change the code, just change
the value of the fee in the table
--
Good Luck
BS"D


:

Thanks for your response but the issue is I don't want the values to be
equal, I want something like if category 1 is selected from the possible 4,
then the fee =20
so on and so forth.


:

Hi fifi
Try this stages
1. To the RowSource of the ComboBox add the "fee" field.
Select category , fee From TableName

2. On the after update event of the combo box, write the code to assign the
fee value to the text box
Me.[TextBoxName] = Me.[ComboName].Column(1)

Note: the column number start with 0

3. If the fee field is to be displayed only, and the user can't update it,
you can set the control source of the text box to
=[ComboName].Column(1)

So you wont need the after update event of the combo from stage 2

--
Good Luck
BS"D


:

hello
I would like to set a value to a text field depending on the value of a
combo box.
for example the combo box has category 1,2,3 and 4.
Now i would like the fee value to display 10 if category 1 is selected
20 if category 2 is selected. so on and so forth.

Your help will be greatly appreciated
 
Back
Top