How do you populate a combobox from an MDB database?

How do you populate a combobox from a certain column and that only has "fan_" somewhere in the text?

Set rs = Myconn.Execute("SELECT DBName FROM DBRecords WHERE DBName LIKE '*" & "fan_" & "*'")
    If Not rs.EOF Then
        cboLoadDB.AddItem rs.GetString
    End If
rs.Close
Set rs = Nothing
Takamine334Asked:
Who is Participating?
 
tonym001Commented:
Try this
Set rs = Myconn.Execute("SELECT DBName FROM DBRecords WHERE DBName LIKE '%" & "fan_" & "%'")
If Rs.EOF = False Then
    Rs.MoveFirst
    Do Until Rs.EOF = True
        'Assumming you want the value
        cboLoadDB.AddItem Rs.Fields(0).Value
        Rs.MoveNext
    Loop
End If
Rs.Close
Set Rs = Nothing
0
 
b0lsc0ttIT ManagerCommented:
If fan_ is somewhere in the middle of DBName then you would use ...

Set rs = Myconn.Execute("SELECT DBName FROM DBRecords WHERE DBName LIKE '%" & "fan_" & "%'")

Access DB uses the percent sign, not the asterisk.  Let me know if you have a question or need more info.

bol
0
 
b0lsc0ttIT ManagerCommented:
I just took a closer look and you don't need to make it three strings.  Use ...

Set rs = Myconn.Execute("SELECT DBName FROM DBRecords WHERE DBName LIKE '%fan_%'")

bol
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
Takamine334Author Commented:
So, if I have more than one item to load in the combobox, how do I do that?
0
 
b0lsc0ttIT ManagerCommented:
What do you mean by a "combobox"?  Since this is in the HTML zone I assume it is a select list but please confirm that.  Where is the code or script for that part?  What is happening right now in your code?

Basically you will need a loop to go through the recordset that is returned by your SQL statement.  However the specifics will depend on what exactly you are making.  I would need more details to help with that.  What language/technology are you using?

Let me know if you have a question about anything I said.

bol
0
 
Takamine334Author Commented:
HTML? I thought I put this in the VB6 section.

I'm trying to load a combo box in VB6. How do I get this over to the VB6 area?
0
 
b0lsc0ttIT ManagerCommented:
I thought that might be the case.  My server side experience with vbscript won't probably be enough to help you much more with this. :)

You will need to post a message in General Community Support (CS from now on) for a moderator to do this.  This question might also be in VB6 but it is in HTML zone too and that won't help you. :)

The message in CS can be started by going to http://www.experts-exchange.com/Community_Support/General/newQuestionWizard.jsp.  Make sure you provide the URL of this question in the message body and let them know what you need.  In this case moving from HTML zone and make sure it is in VB6.  No points are needed for the question and make sure only the General zone in Community Support is selected.  Let me know if you have a problem or need help with this.

I'll still keep an eye on this and help more if I can.  Let me know if you have a question about anything I said.

bol
0
 
Takamine334Author Commented:
Tony - I'm trying to split that value:

music = Split(rs.Fields(0).Value, "musician_")

I get a RT 13 type mismatch. Any ideas?
0
 
Takamine334Author Commented:
Actually, this seemed to work.

music = rs.Fields(0).Value
music = Split(music, "musician_")(1)
music = Replace(music, "_", " ")
music = Replace(music, "''", "'")
music = Trim(music)
       
cboLoadDB.AddItem music
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.