Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
Visual Basic Forum for Visual Basic Programmers VB Forum Index » General

Post new topic   Reply to topic
Ruturn data from DB based on selection in combobox
View previous topic :: View next topic  
Author Message
Act2
Newbie


Joined: 01 Mar 2006
Posts: 1

PostPosted: Mar 1st, 2006 08:08 PM    Post subject: Ruturn data from DB based on selection in combobox Reply with quote

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
View user's profile Send private message
dougthomas
Moderator


Joined: 27 Jul 2005
Posts: 271
Location: Essex, UK

PostPosted: Mar 2nd, 2006 05:55 AM    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Visual Basic Forum for Visual Basic Programmers VB Forum Index » General All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Visual Basic Forum runs phpBB | Forum Template © iOptional
VB Resources | SSL | Visual Basic