Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 191
  • Last Modified:

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
0
Takamine334
Asked:
Takamine334
  • 4
  • 4
1 Solution
 
b0lsc0ttCommented:
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
 
b0lsc0ttCommented:
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
 
Takamine334Author Commented:
So, if I have more than one item to load in the combobox, how do I do that?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
b0lsc0ttCommented:
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
 
b0lsc0ttCommented:
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
 
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
 
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now