473,387 Members | 1,532 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.

Selecting A Column from a Table

4
Hi,

although I was intensely searching the web, I couldn't find an answer for the following problem:

I have a set of different price lists organized in a table (articles as rows, different prices as columns) and I have a set of different customers in a table. Now I want to generate a query combining a specific customer with a specific price list - in other words, select a specific column from the price list table.

As I am a bloody beginner in VBA and SQL I would appreciate if answers could include Code examples.

Thank you

Al
Aug 16 '07 #1
6 2060
Stwange
126 Expert 100+
I need a bit more information, does the customer have a field telling it which of the price lists it should use? Or will you be changing this each time?

eg. is there a Customer.[priceList] which is identical to the field name you want to return from product?

Please provide an example.
Aug 16 '07 #2
BigAl
4
I need a bit more information, does the customer have a field telling it which of the price lists it should use? Or will you be changing this each time?

eg. is there a Customer.[priceList] which is identical to the field name you want to return from product?

Please provide an example.
The relation customer to price list is fixed, so every time the customer gets the same price list. the "Customer.[priceList]" could be implemented.

In terms of example, what do you need? a dummy data base? just some described scenarios?

thanks for your interest in helping me

Al
Aug 16 '07 #3
Stwange
126 Expert 100+
The relation customer to price list is fixed, so every time the customer gets the same price list. the "Customer.[priceList]" could be implemented.

In terms of example, what do you need? a dummy data base? just some described scenarios?

thanks for your interest in helping me

Al
I'm not sure if this is possible with one query.
you could do several queries (ie, one for each price), and then use code to select which one is run.
Or, possibly a better idea, you could have a combobox allowing you to select a customer, and then using the information in this, populate a two-column listbox with ARTICLE and PRICE.
Which would be better? Or, ideally, tell me what you want to do with this query once it's done, as it may be easier just to do whatever that is directly.

It may be tomorrow before I can reply again.
Aug 16 '07 #4
BigAl
4
I'm afraid the thing is not quite so easy. First we are talking about approx. 500 individual prices and second, even worse, not all price lists contain all prices.

I like the second option, the combobox, although, I admit, I am not sure how to do this.

And answering your question, the resulting query should be used to generate a report for printing out a price list.

Thank you really for your help

Al
Aug 16 '07 #5
Stwange
126 Expert 100+
I'm afraid the thing is not quite so easy. First we are talking about approx. 500 individual prices and second, even worse, not all price lists contain all prices.

I like the second option, the combobox, although, I admit, I am not sure how to do this.

And answering your question, the resulting query should be used to generate a report for printing out a price list.

Thank you really for your help

Al
First, create a combobox (call it cmbCustomer) and make it whatever size you want. Second, create a listbox (called lstPriceList), and go into its properties and change column count to 2 In the combobox properties, set the Row/Source Type to "Table/Query" and change the RowSource to:

'"SELECT name FROM Customer ORDER BY name;" (or whatever your field and table is called)

Then, still in the properties, go to the ON EVENT tab and click AFTER UPDATE -> click the "..." and click CODE GENERATOR.
In that code that comes up, write:

Expand|Select|Wrap|Line Numbers
  1. Dim rs As DAO.Recordset
  2. Set rs = DBEngine(0)(0).OpenRecordset("SELECT price FROM Customer WHERE name = '" & cmbCustomer.Value & "';")
  3. lstPriceList.RowSource = "SELECT article_name, " & rs!price & " FROM Article;"
  4. lstPriceList.Requery
Then try opening the form, and selecting a particular customer. If the listbox doesn't update automatically, try clicking off the combobox. I haven't tested this code, so if you have problems, please let me know. Good luck.
Aug 17 '07 #6
BigAl
4
Thanks for all your help. I overcame the problem with two night shifts, reorganizing the data completely. For the moment it works just fine.
Aug 25 '07 #7

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

Similar topics

3
by: James Lee | last post by:
I am doing a simple query like col1, col2, date, col4 from table1. All four colums are of type blob. For date column, I store a string like this: Fri Feb 13 11:01:24 2004 I store records as...
4
by: remote89 | last post by:
Hi experts, I have been trying to limit the table rows in the following situation, any suggestions will be appreciated. we have table called tempTb has columns id, c_id, c_name, rating, date...
4
by: Lucius | last post by:
Hello everyone, I have a query problem. I'll put it like this. There is a 'publishers' table, and there is a 'titles' table. Publishers publish titles (of course). Now I want to make a query (in...
5
by: uthuras | last post by:
Machine : AIX 5.2 Product : UDB DB2 Release 8.1 FP4a I have problem loading data into destination table. The data file is huge with more than 6 Million records. This what i have done 1....
4
by: Doslil | last post by:
I have a form which has a subform.In the main form I have only one field (this is a drop down list and has a query attached to it) which selects empno,Name from the EmployeeInformation table. ...
3
by: klawiter | last post by:
Greetings, I have a table with two columns. On my form, I have a combo field that displays the contents of the first column. Upon selecting an item in this combo field, I would like to then...
8
by: Kari Lavikka | last post by:
Hi! I have to select a random row from a table where primary key isn't continuous (some rows have been deleted). Postgres just seems to do something strange with my method. -- -- Use the...
5
by: Mahesh S | last post by:
Hi I would like to write a SQL select statement that would fetch rows numbered 50 to 100. Let me clarify, if i say "fetch first 10 rows only", it returns the first 10 rows from the resultset....
2
by: movieking81 | last post by:
If someone could help me with this, that would be great. I need to select a number of records from an SQL table based on a date range, so I started with this select. <html> <code> resultssql =...
5
by: hollyquinn | last post by:
Hi I am working with a web application where I am selecting values from a SQL Server 2005 database and then loading the values into different controls on my page. Most of the values load with no...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.