Help ! Display values from tables!

When I put the comma as you mentioned, there is no error.
 
When I put the comma as you mentioned, there is no error.
 
Is 'myCboBox' the name of your combo box?
 
Combo454 is the name and Lines 3 is the Control source
 
oh...

We need to back up a little. To start with, lets get away from the combo box and consider a simple text box on a form where you enter data. Say you have a form name 'Customers' and on this form you have a text box named 'customerName'.

In code, you would refer to the data in the text box by using:

forms!Customers!customerName

A short cut is:

me!customerName

But if you use this shortcut, the code must be in the same form that the text box is in. Say if I had another form that was open named 'Vendors', in that forms code, if I wanted to refer back to the text box back in the customers form, I could not use me!customerName. You'd have to use forms!Customers!customerName.

Make sense????
 
KenHigg said:
oh...

We need to back up a little. To start with, lets get away from the combo box and consider a simple text box on a form where you enter data. Say you have a form name 'Customers' and on this form you have a text box named 'customerName'.

In code, you would refer to the data in the text box by using:

forms!Customers!customerName

A short cut is:

me!customerName

But if you use this shortcut, the code must be in the same form that the text box is in. Say if I had another form that was open named 'Vendors', in that forms code, if I wanted to refer back to the text box back in the customers form, I could not use me!customerName. You'd have to use forms!Customers!customerName.

Make sense????

Ok that means, I should write the code snippet the following way:

forms!Add Promo Details!Product Price 3 = [Me].[Combo454].Column(1)

Here: Add Promo Details is the form name
Product Price 3 is the field where we want to display the price
Combo 454 is the combobox where we are selecting the product

Is this what I should do?
 
Yes. Now you're getting there! What does it do now?
 
One more note - If you have spaces in the names, you must use brackets:

forms![Add Promo Details]![Product Price 3] = [Me].[Combo454].Column(1)
 
Same Error as in the earlier attachment:
cannot find the field '|' refererred in your statement.
and the statement is:
Forms![Add Promo Details]![Product Price 3] = [Me].[Combo454].Column(1)
 
OK... (Whew!...)

Comment this out for a minute (Just put the apostrophe in front).

Here's how I typically start trouble shooting stuff:

Add this:

msgbox Forms![Add Promo Details]![Product Price 3]


And see what happens...
 
Hi Ken,
Thanks for the help. So, now it has worked. It shows Product Price 3 value as 0 in the message box, as default is zero
I assigned the value from the combobox to the Product Price 3.
Then it shows me the actual value from table in the message box.
So both parts work now.
Now as next step, I want to display the price on the form. When I give the control source for a text field as Product Price 3 and in the expression the combo box expression, it does not get refreshed although product price 3 is the value from the table..
What could be the problem?
 
So the code you have working is in the after update event of the combo box?
 
Ok, now lets see if we can get the correct data out of the combo box...

Try this in the after update event of the combo box:

msgbox [Me].[Combo454].Column(1)

And see what happens...
 
What is the sql string you have for the rowsource in the combo box?
 
Hi Ken,
It has worked. The only problem is that the values do not get refreshed immedietly. I am using Tab Pages. So If I go to next page and comeback the values are refreshed.
One more small question on this.
After the prices are displayed, I wanted to calculate the order discount depending on price.
So if the customer is Premium ( This comes out from the table), then the customer gets 10% discount on the Product Price, which we have retrieved from the table.
How and where should I put the IF condition and with what syntax?
I would appreciete you response and thanks for your help.
Regards
K
 

Users who are viewing this thread

Back
Top Bottom