Solved

recordset query to multiple records

Posted on 2000-02-20
13
278 Views
Last Modified: 2010-05-02
I have a table in access that consists of three columns.
column headings: Heading,Key,SupplierKey

I open a recordset from my form to select * from table WHERE SupplierKey = "something"
This recordset fills up a combobox

Combobox_click event
When I select an item in the combobox, I want the recordset to move to a record in the recordset where the combobox.text returns the value of recordset!Key (this will be the value for text1.text)

How do I do this. Please help!
I thought about INNER JOIN, but I don't want to join two tables.
The 'Heading' column can have the same value e.g Keyboards, but the 'Key' column identifies which record I want.
The reason I am selecting records from the 'SupplierKey' column to open the recordset, is because this is being selected from a different combobox.  

Thanks for the answer!!!
0
Comment
Question by:andre_vil
  • 5
  • 3
  • 2
  • +2
13 Comments
 
LVL 6

Expert Comment

by:Marine
ID: 2540413
Ok let me understand this right. The comboBox gets filled correct ? Then when selecting an item from it you want to show a value for selected item? is this right ?
0
 
LVL 6

Expert Comment

by:esolve
ID: 2540468
The combobox gets filled correct!
When I select an item it displays the record's 'heading'. With this displayed, I want to fill up a textbox with the record's correspondent 'key'.

Since the recordset is open I can show any value for recordset!Key with the following code:

rs.movefirst
text1.text = rs!key

this returns the first value for 'key' but not the record which is selected in the combobox!

help!
 
0
 
LVL 6

Expert Comment

by:Marine
ID: 2540476
Ok try this so in your listbox click event place this
and read it form a recordset on every click on the item
select Key from table WHERE SupplierKey =" & list1.listindex
and just assign that value to your textbox.
0
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
LVL 6

Expert Comment

by:esolve
ID: 2540532
When I do this I have to open a new recordset.
I want to do something like this:
SELECT key FROM previousRecordset WHERE SupplierKey = combobox.text
I know this wouldn't work but since I have selected items from the table, I have to query these items again to get the records I want.

Hope you understand what I want to do!
Thanks
0
 

Author Comment

by:andre_vil
ID: 2540546
Adjusted points to 50
0
 
LVL 6

Expert Comment

by:Marine
ID: 2540556
You will still have to query to get the selected record from to combo. Thats why i suggestd to open a new recordset.
SELECT key FROM previousRecordset WHERE SupplierKey =" & combobox.ListIndex
0
 

Author Comment

by:andre_vil
ID: 2540565
Can you make a query to two items from a record in a table.
i.e SELECT key, supplierkey FROM table WHERE key = "" and supplierkey = "" 
0
 
LVL 6

Expert Comment

by:Marine
ID: 2540590
yes you can .
I don't know if your fields are numeric type or string so this one is for numeric
rs = "SELECT From table where key=" & combo1 & "AND" & setkeys = " & combo1"

and this one for string
rs2 = "SELECT * FROM TABLE where table1='" & text1.Text & "' & " And " & setkeyset='" & text2.Text & "'"
0
 

Expert Comment

by:TT
ID: 2540938
U can try this,
  rs.FindFirst "SupplierKey = '" & _
      Combo1.Text & "'"    
  If Not rs.NoMatch() then
      Text1.text = rs.Key
  EndIf
0
 
LVL 6

Expert Comment

by:Marine
ID: 2540981
He needs to serach by 2 feilds . If he is using ADO theer is no fiddifsrt also find can search one creteria . Must use Filter 2 search more
0
 

Accepted Solution

by:
sonere earned 50 total points
ID: 2541718
You use a text box depends on adodc1 (datasource) and datafield key

when the recordset order and combobox is the same and after combo1 click


Adodc1.Recordset.AbsolutePosition = Combo1.ListIndex + 1

write this statement
You can see the key in the text box

best wishes.

Sonere
0
 

Author Comment

by:andre_vil
ID: 2543252
Thanks a lot Sonere!
This is what I want. i am not using a ADOData control, but it applies to my project as well.

Regards
André
0
 

Expert Comment

by:sonere
ID: 2543787
Dear andre_vil,

Nice to see your comment like this. Good programs in VB



0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question