| View previous topic :: View next topic |
| Author |
Message |
Act2 Newbie
Joined: 01 Mar 2006 Posts: 1
|
Posted: Mar 1st, 2006 08:08 PM Post subject: Ruturn data from DB based on selection in combobox |
|
|
I’m very new to VB6 but have used Access a lot. My question is on the Data
Control. What I want to do is this. I have an unbound combo box which displays the name of the current XP windows printer default. I want to take the combobox information and look up a custom name that I have associated with it in a Assess 2000 DB. And return the string to a listbox on the form. The database has three fields ID, NetworName and CustomName.
Something like this.
Network Printer Name = “HHH-kr-1234” Custom name = “Color printer NE office
” I have tried this code with no luck.
I have tried the following code but the return is not synicted to the combobox, it just returns the firs record in the table.
| Code: |
Data1.DatabaseName = "C:\PrtFind\PrinterDefaultv1.mdb"
Data1.Recordset.MoveFirst
Data1.Recordset.FindFirst "[PrtName] = 'CboHold'"
Me.CustPrintName = Data1.Recordset.Fields("PrtCustomName")
If Data1.Recordset.NoMatch Then
Data1.Recordset.MoveFirst
End If
Data1.Recordset.MoveFirst
Do While Not Data1.Recordset.EOF
Me.Combo1.AddItem Data1.Recordset![PrtCustomName]
Data1.Recordset.MoveNext
Loop
Any help will be great. Thanks
|
|
|
| Back to top |
|
dougthomas Moderator
Joined: 27 Jul 2005 Posts: 271 Location: Essex, UK
|
Posted: Mar 2nd, 2006 05:55 AM Post subject: |
|
|
Hi,
I expect your FindFirst is always failing.
I think you may mean
| Code: |
Data1.Recordset.FindFirst "[PrtName] = '" & CboHold & "'"
|
Assuming that the value you are looking for is in the variable cboHold. At the moment you're looking for the string 'cboHold' in the recordset.
Regards
Doug _________________ If you can see the light at the end of the tunnel, it probably means there's a Train coming. |
|
| Back to top |
|
|