Results 1 to 2 of 2

Thread: [RESOLVED] ENUM values into combo

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2008
    Posts
    12

    Resolved [RESOLVED] ENUM values into combo

    Hi,

    How do i populate ENUM values into a combobox from structure below. Thanks

    Create table myTable(
    title ENUM ('Mr', 'Mrs', 'Miss') NOT NULL DEFAULT 'Mr'
    );

  2. #2
    Lively Member
    Join Date
    Jun 2008
    Location
    Bayang Magiliw, Perlas Ng Silangan
    Posts
    100

    Re: ENUM values into combo

    i'm not sure why you wanna populate your combobox from the database with this kind of data. i.e. 'Mr', 'Mrs', 'Miss'

    a simple way to do that is:

    right click on combobox
    select Properties
    on Properties look for
    List
    click the arrow button
    then enter 'Mr', 'Mrs', 'Miss' on the list

    if it really is necessary that you use database then hope this will help. It would give you a start.

    Code:
    Dim strSql As String
    Dim conn As ADODB.Connection
    Dim rs As ADODB.Recordset
    
    Set conn = New ADODB.Connection
        conn.Provider = "Microsoft.Jet.OLEDB.4.0 "
        conn.Open ("C:\yourAppLocation\yourDB.mdb")
    Set rs = New ADODB.Recordset
    
    strSql = "SELECT title FROM myTable"
    
    rs.Open strSql, conn, adOpenStatic, adLockOptimistic
    
    If rs.BOF And rs.EOF Then Exit Sub
    
    rs.MoveFirst
    
    Do While Not rs.EOF
        Me.Combo1.AddItem rs.Fields(0)
        rs.MoveNext
    Loop
    
    Set conn = Nothing
    Set rs = Nothing
    Last edited by nubie; Jun 30th, 2008 at 03:55 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width