|
-
May 10th, 2001, 01:11 PM
#1
How would you all do this?
Problem description: I need to load a record based on an alphanumeric primary key field of a table selected from a dropdown combo box. Then, i need a command button that when clicked, will display the record in the approriate text boxes. For example, the user will select a project number (alphanumeric) from a project table using a datacombo box. then, all the text boxes will populate with the appropriate fields from the table. I've tried numerous ways to do this to no avail. I'm a beginner at this so i would appreciate any help i can get. Thanks in advance.
-
May 10th, 2001, 01:22 PM
#2
Re: How would you all do this?
The combobox has a Click event. in there, grab what was selected (Combo1.List(Combo1.ListIndex)) will return to the text of the chosen. Now issue your SQL statement with this value as the WHERE clause. Once you get your recordset back - assign the text boxes their respective values.
if you need more detail - let me know.
john
John Pirkey
MCSD
http://www.ShallowWaterSystems.com
http://www.stlvbug.org
John Pirkey
MCSD (VB6)
http://www.stlvbug.org
-
May 10th, 2001, 01:29 PM
#3
Re: How would you all do this?
Thanks for your reply Johnny. I've tried that, and I got errors, but I think my problem is that i'm trying to use ADO and haven't fully grasped the concept such as opening connections and stuff like that. So what i guess i'm saying is yes I do need more detail. Thanks again.
-
May 10th, 2001, 02:15 PM
#4
Re: How would you all do this?
well, something like this:
private Sub Combo1_Click()
dim sql as string
dim rs as adodb.recordset
sql = "SELECT * FROM YourTable WHERE ProductNumber = '" & Combo1.List(Combo1.Listindex) & "'" '
set rs = new adodb.recordset
set rs = YourConnectionObject.Execute(sql)
if not rs.eof then
txtProductName.Text = rs!ProductName
txtProductCode.Text = rs!ProductCode
txtProductPrice.Text = rs!ProductPrice
rs.close
end if
set rs = nothing
End Sub
something like that shoud work for what you want.
hope this helps,
john
John Pirkey
MCSD
http://www.ShallowWaterSystems.com
http://www.stlvbug.org
John Pirkey
MCSD (VB6)
http://www.stlvbug.org
-
May 10th, 2001, 02:18 PM
#5
Re: How would you all do this?
thanks , I will try it. Let you know what happens!
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
|