|
-
Nov 22nd, 2000, 08:02 AM
#1
Thread Starter
Lively Member
Hi
I am a bit stuck with the following...
I have an Access DB and would like to access the data through a VB App I have created.
I have the following columns setup in the table:
CustomerName, CustomerID,ItemPurchased, DateofPurchase.
In a listbox in my app I simply want to display the Customer name and when it is clicked bring up the customer record. I have no problems getting to Access through my app. The problem is ensuring that the correct record is selected when the app queries the DB. To get round this I now have listed in the app listbox: CustomerName and CustomerID rather than just CustomerName. In the DB I have created a new colum that contains "CustomerName and CustomerID".(ie. combining 2 tables to form another table, therefore quite amount of duplication) So my program now compares exactly what`s in the listbox to what`s in the new column of the DB.
Is this the only way this can be done through VB? It just seems quite primative / simple??...or is there something I can do with the Listbox?
Any help or ideas would be greatly appreciated
Thanks in advance
Kelly
-
Nov 22nd, 2000, 08:57 AM
#2
Addicted Member
ok instead of creating a new table in access go back to the table you had before and show just the customers name in the list box
now there is an invisible field that is part of each listitem in a listbox, it is called itemdata this field is invisible but you can access it. then all you would need is a query with the argument of customerid(im assuming this is your primary key) then whenever they click a customer name you access itemdata and get the customerid pass it to your query and get you data.
Code:
customerid = lstCustomers.ItemData(lstCustomers.ListIndex)
customerid would be your parameter for your query...
simple invisble to the user and effective...
 ender_pete 
C#,VS.NET Ent Arch, vb6 ee sp5,html,vbscript,jscript,
xml,dhtml,delphi,c++,vc++,java,cgi,php, python, ada(so ancient) ,adasage(also ancient) and others i can't remember.....
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|