|
-
Aug 8th, 2005, 12:47 AM
#1
Thread Starter
Member
combo boxes - query
Hi, I have a problem regarding combo boxes. I want to add a combo box to a form such that when any item on it is selected the remaining text fields on the form are automically filled from a table depending upon the selected item.
For example, if the combo box has a list of products. When the user selects a particular product and presses go, the text fields on the same form are filled up with the product details (by looking up a table based on the selected product). I am a looking for a solution without the use of subforms.
Thanks
-
Aug 8th, 2005, 01:15 AM
#2
Hyperactive Member
-
Aug 8th, 2005, 01:25 AM
#3
Thread Starter
Member
Re: combo boxes - query
Thanks a lot Sri, I got the idea through your attachment. Can you also perhaps tell me how can I use a query for the solution. Thanks
-
Aug 8th, 2005, 01:31 AM
#4
Hyperactive Member
Re: combo boxes - query
VB Code:
Private Sub Combo0_AfterUpdate()
Dim sql As String
Dim rst As Recordset
sql = "Select empname from table1 where empno=" & Me.Combo0.Value & ";"
Set rst = CurrentDb.OpenRecordset(sql)
If Not rst.RecordCount = 0 Then
Me.Text4 = rst!empname
End If
End Sub
chk out this...but..comparitivly this code will take more time than previous one..
The Difference between a Successful person and others is not a Lack of Knowledge,
But rather a Lack of WILL 
-
Aug 8th, 2005, 03:05 AM
#5
Thread Starter
Member
Re: combo boxes - query
thanks sri, you were great
-
Aug 8th, 2005, 04:09 AM
#6
Re: combo boxes - query
Optimisation hint:
If you run a query to fill the list box, then fill it with the other data you want to display on the form, but in hidden columns (column widths of 0).
Then as the user selects the item from the dropdown, you use after update or click events to take the hidden columns data of the selected item and put it into the text box fields on the form. Makes it look faster on seleccting, but a little slower (negligable) on filling the dropdown.
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
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
|