Link to home
Start Free TrialLog in
Avatar of Takamine334
Takamine334Flag for United States of America

asked on

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
Avatar of b0lsc0tt
b0lsc0tt
Flag of United States of America image

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
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
Avatar of Takamine334

ASKER

So, if I have more than one item to load in the combobox, how do I do that?
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
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?
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 https://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
ASKER CERTIFIED SOLUTION
Avatar of tonym001
tonym001

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Tony - I'm trying to split that value:

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

I get a RT 13 type mismatch. Any ideas?
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