Hello everyone,
I'm a ColdFusion programmer whose been tasked with creating a VB6 application for the marketing department of my company. It's a simple application, and here's basically how it works:
You search for a product from a textbox. The results of the search populate a combo box. When you select something from the combo box, it populates a series of text fields with information about the product (title, format, catalog number, price, etc...). From there you can click an "add to shopping cart" button, which stores that product into a shopping cart database table. Make sense so far?
Okay, so I have the search working. What I can't get is populating the combo box and subsequent text fields once you select something in the combo box. After reading a few of the books we have lying around, I figured it would be best to create a UDT to store the information. So I did that:
VB Code:
Private Type ProductUDT the_title As String Title As String Format As String Price As String ID As String SKU As String End Type Dim Products() As ProductUDT, i As Long
Then I run the query:
VB Code:
Dim SQL_Search As ADODB.Recordset Set SQL_Search = New ADODB.Recordset Dim searchtext As String searchtext = txt_search.Text SQL_Search.Source = "SELECT (title & '('&Format&')') As the_title, title, ID, format, sku, price FROM lkpProduct WHERE (title LIKE '%" & searchtext & "%') OR (sku LIKE '%" & searchtext & "%') ORDER BY title" Set SQL_Search.ActiveConnection = db SQL_Search.Open
Then I have the code to populate the combo box (but it doesn't work yet):
VB Code:
For i = LBound(Products) To UBound(Products) combo_search_results.AddItem Products(i).Title combo_search_results.ItemData(combo_search_results.NewIndex) = i Next
Based on what the book says, there needs to be code to tie together the query results to the "Products" UDT that is created. Unforunately, the author purposely omitted the code to do that.
If someone can please help me to figure out (a) how to tie the query to the UDT; and then (b) how to tie the query information from the selected item in the combo box to the text fields.
MUCH APPRECIATED! The bosses will be pleased if I can get this working.
Josh Sager
www.tlavideo.com




Reply With Quote