Results 1 to 3 of 3

Thread: SQL 7 database access

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2000
    Posts
    81
    i have gained access to my database using the below
    code but what i want to do is load my query result of all
    the interviewers into my combobox named cmbInterviewer
    now this is where i get stuck
    thankyou for all yor replys





    Code:
    Dim dyna As Recordset
    Dim theerror As Long
    
    SQL = "select interviewername  from interviewer"
        Set dyna = db.OpenRecordset(SQL, dbOpenDynaset, dbSQLPassThrough + dbSeeChanges)
            theerror = Err
    On Local Error GoTo 0
    
    cmbInterviewed.Clear
    
    Select Case theerror
    Case 3146
    'case 3146 means there are no records in the database
    
    Case 0
    'this is where i want to put my coding

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    If you are using a datacombo then it would go like this:
    Code:
    'just set the datasource for the data combo
    set cmbInterviewed.Rowsource=dyna
    cmbInterviewed.Listfield="Interviewed"
    cmbInterviewed.refresh
    or if you are using a regular combo then it would go like this:
    Code:
    MaxRec=dyna.recordcount
    for x=1 to MaxRec
       'just scroll thru the recordset and add the field info you want to the combo
       cmbInterviewed.additem dyna!Interviewed
       dyna.movenext
    next x
    [Edited by Edneeis on 11-02-2000 at 09:41 PM]

  3. #3
    Guest
    Or try this:

    Code:
    While Not Dyna.EOF
        cmdInterviewer.AddItem Dyna.Fields("InterviewerName").Value & ""
        Dyna.MoveNext
    Wend
    That should get around the need to check for empty recordset, adn the ' & "" ' at the end of the additem line will stop NULL values beign inserted, which crashes combos

    cheers

    - gaffa

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