473,387 Members | 1,456 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

In a combo box I need to get more than one value from the query

Hello!
I will try to explain the problem clearly
I am creating a database for my business (restaurant)
I have a table and a form called ‘suppliers’ which work perfecty well
The second table and form is called ‘products’
The fields are: ProductCode
Name
ProductType
TaxesType
A third table called ‘TaxPercentage’ consists of two fields:
TaxIndex
Percentage
A fourth table and form is called ‘Invoice’
The form ‘Invoice’ has a subform called ‘ProductInput’
And it is in this subform that I have the problem
It consists of the following fields:
Code
InvoiceCode
ProductCode
etc, etc
I use a combo box to get the name of the product
I set ‘Row source’ to a query that by means of ‘Name’ I get
The ‘ProductCode’
I set ‘Control source’ to ‘ProductCode’
But I should also get ‘ProductType’ and ‘TaxesTypes’ to get the percentage
from the ‘TaxPercentage’ table and put them in ‘ProductInput’ fields

I am sorry this seems to be badly expressed
Making a summary of it all I asked these questions:
In a combo box, by means of a query, how can I get the other fields of the table?
(I only get one)

If I have the value of a table field (say the code of a product)
How can I get other field values and with these get other values from
other tables?
Can this be achieve easily or should I do it with Visual basic?
Thanks for your time!

Joey
Nov 20 '06 #1
6 1782
willakawill
1,646 1GB
Hello!
I will try to explain the problem clearly
I am creating a database for my business (restaurant)
I have a table and a form called ‘suppliers’ which work perfecty well
The second table and form is called ‘products’
The fields are: ProductCode
Name
ProductType
TaxesType
A third table called ‘TaxPercentage’ consists of two fields:
TaxIndex
Percentage
A fourth table and form is called ‘Invoice’
The form ‘Invoice’ has a subform called ‘ProductInput’
And it is in this subform that I have the problem
It consists of the following fields:
Code
InvoiceCode
ProductCode
etc, etc
I use a combo box to get the name of the product
I set ‘Row source’ to a query that by means of ‘Name’ I get
The ‘ProductCode’
I set ‘Control source’ to ‘ProductCode’
But I should also get ‘ProductType’ and ‘TaxesTypes’ to get the percentage
from the ‘TaxPercentage’ table and put them in ‘ProductInput’ fields

I am sorry this seems to be badly expressed
Making a summary of it all I asked these questions:
In a combo box, by means of a query, how can I get the other fields of the table?
(I only get one)

If I have the value of a table field (say the code of a product)
How can I get other field values and with these get other values from
other tables?
Can this be achieve easily or should I do it with Visual basic?
Thanks for your time!

Joey
Hi Joey,
One way of doing this is to concatenate the values from your query into a single string value with a field name alias of your choice and set the control source to that field name, in this case ProdDetails:
Expand|Select|Wrap|Line Numbers
  1. SELECT ProductCode & ", " & ProductType & ", " & TaxesType As ProdDetails
  2. FROM Product
  3.  
Nov 20 '06 #2
Hi Joey,
One way of doing this is to concatenate the values from your query into a single string value with a field name alias of your choice and set the control source to that field name, in this case ProdDetails:
Expand|Select|Wrap|Line Numbers
  1. SELECT ProductCode & ", " & ProductType & ", " & TaxesType As ProdDetails
  2. FROM Product
  3.  
Thanks for helping but I think I have not explained the problem very well

Now the other two fields are showing in the combo control but what I need
is to use the other fields of the record I choose to get access to other
tables.
Supose I have two products:
Wine and Milk
When I choose milk I need the taxesPercentage to go to the other table,
extract the value and place it in ProductInput table

It seems the more I write the more complicated it is
I am sorry
Nov 20 '06 #3
willakawill
1,646 1GB
Thanks for helping but I think I have not explained the problem very well

Now the other two fields are showing in the combo control but what I need
is to use the other fields of the record I choose to get access to other
tables.
Supose I have two products:
Wine and Milk
When I choose milk I need the taxesPercentage to go to the other table,
extract the value and place it in ProductInput table

It seems the more I write the more complicated it is
I am sorry
Try this or some variation
Expand|Select|Wrap|Line Numbers
  1. Dim ar As Variant
  2.  
  3. ar = Split(Combo1.Text, " ")
  4.  
  5. 'blah blah blah
  6.  
  7. ...WHERE Field1 = '" & ar(0) & "'"
  8.  
  9. ...WHERE Field2 = " & CInt(ar(1))
  10.  
Nov 22 '06 #4
I am sorry but I do not understand!
Maybe I have not explained the problem very well
This is an explanation that could be clearer:


I have two tables:

The first table is called:
Products
it has the following fields
ProdName
ProdId
ProdType
ProdTaxes

The second table is called:
ProductInput
with the following fields
ProductId
Quantity
Price
TaxPercentage
...and others...

I have made a form based on table 'ProductInput'
I use a combo to get the ProdId (Products table) by means of
ProdName (Products table) and I put it in ProductId (ProductInput table)

My question is:
How can I get the corresponding record in the table 'Products' using
ProductId (ProductInput table), to extract the other fields (like ProdType
and ProdTaxes -Product table-) and put them in the fields TaxPercentage,
Price, etc of ProductInput table.

Thanks for your time!
Nov 22 '06 #5
willakawill
1,646 1GB
I am sorry but I do not understand!
Maybe I have not explained the problem very well
This is an explanation that could be clearer:


I have two tables:

The first table is called:
Products
it has the following fields
ProdName
ProdId
ProdType
ProdTaxes

The second table is called:
ProductInput
with the following fields
ProductId
Quantity
Price
TaxPercentage
...and others...

I have made a form based on table 'ProductInput'
I use a combo to get the ProdId (Products table) by means of
ProdName (Products table) and I put it in ProductId (ProductInput table)

My question is:
How can I get the corresponding record in the table 'Products' using
ProductId (ProductInput table), to extract the other fields (like ProdType
and ProdTaxes -Product table-) and put them in the fields TaxPercentage,
Price, etc of ProductInput table.

Thanks for your time!
I assume you are using bound controls and want Access to fetch the fields provided that you set things up correctly.

I don't know how to do that. I do know how to write the code that will do it. It may be that you are at the crossing over point where you decide that you want to start writing the code yourself. This would be a good project to learn on.

You can use the ProductID to query either table.
Nov 23 '06 #6
Hi!
I have started to read a book about VBA
I think I need it!
Thanks for your help!
Nov 24 '06 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: FZ | last post by:
Hi Gang, I was wondering if a generous person might be able to walk me through what I believe is a pretty simple task. I actually have significant Access experience, but I haven't done it in...
5
by: Dalan | last post by:
I have been searching the archives in an effort to discover how to derive a dual use of a single combo box - so far no go. I found the piece below which pretty much represents the usage. To...
10
by: Bob Darlington | last post by:
I am using the following SQL as a RowSource for a combo box on a form. "SELECT LAN, TenantName as , ShopNum as FROM qTenantSelect " The field 'ShopNum' is a text field and has a caption...
8
by: Lyn | last post by:
Hi, Can anyone tell me how the initial value displayed in Combo Box is determined when a form is opened? I am loading the dropdown from one field ("CategoryName") of a table, with "ORDER BY ". ...
4
by: jcazmail-groups | last post by:
I have a child form that has a combo box whose underlying query needs to be filtered by a value from a combo box on the parent form. I have succeeded in doing this by putting the following SQL in...
11
by: my-wings | last post by:
I think I've painted myself into a corner, and I'm hoping someone can help me out. I have a table of books (tblBooks), which includes a field (strPubName) for Publisher Name and another field...
4
by: LD | last post by:
Is there a way in Access to store more than one value in a field that has been selected from a combo box? For example, if a combo box had three values that you can select, "One", "Two", and...
3
by: fstenoughsnoopy | last post by:
Ok the complete story. I have a Contact Table, Query and Form, that are used to input and store the contact info for customers. They have FirstName, LastName and Address as the primary key...
8
by: salad | last post by:
I was wondering how you handle active/inactive elements in a combo box. Let's say you have a combo box to select an employee. Joe Blow has been selected for many record however Joe has left the...
2
by: lottaviano | last post by:
I have a form with two combo boxes. The value chosen in the first combo box (cbo1) is supposed to change the values that appear in the second combo box (cbo2). This currently works great for the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.