Results 1 to 3 of 3

Thread: Standard Modules Help please

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2000
    Posts
    103
    i have a combo button on my form from which
    i want to set them up with data from MY sql7 database
    i have a Standard Module

    From my form load event of my form i want to
    open a publicfunction in my Standard Module that opens my database and then loads my sql query result into my
    combobox on my main form.

    my question is this:
    why from my module is my combobox out of scope and
    how do i declare the combobox so its in scope
    the combobox is called cmbInterviewer:
    the below code is in my module

    Code:
    Public Function SetupHistoryCombo()
    
    Dim dyna As Recordset
    Dim theError As Long
    Dim theid As Long
    Dim myarray As String
    
    
    SQL = "select InterviewerShortDesc from interviewer"
        Set dyna = db.OpenRecordset(SQL, dbOpenSnapshot, dbSQLPassThrough + dbSeeChanges)
        
        theError = Err
        
    On Local Error GoTo 0
        
    Select Case theError
    Case 0
        Do Until dyna.EOF
            cmbInterviewed.AddItem = dyna("InterviewerShortDesc")
            'this code above, the method additem does not work???
            
            
            
           dyna.MoveNext
        Loop
        dyna.Close
        Set dyna = Nothing
    Case 3146
        'No data
    Case Else
        MsgBox Error
    End Select
    End Function

  2. #2
    Addicted Member Ramandeep's Avatar
    Join Date
    Feb 2000
    Posts
    158
    You say your combo is called cmbInterviewer, but I see
    cmbInterviewed in your code?

    Try refrencing the form before the cobobox name

    Example:

    formName.cmbInterviewed.additem...

    where formName is the form containing the combobox?

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Sep 2000
    Posts
    103

    i am

    i am calling my module from the form load event
    so when in the module i use
    Code:
    frmCandidate.cmbInterviewed.AddItem dyna("InterviewerShortDesc")
    it gets to this code then pops out of my function back at the form load event then gets to the part in the form load event that calls my function in my module and does a complete loop which i dont want
    i have seen people declare in there module functions
    Code:
    Public Function SetupHistoryCombo(cmbinterviewed as combobox)
    what does this mean i have tried it this way and in my module when i type my comboboxname. i can see the different
    options i can use with this control
    but when i run the project i get an error when my fuction is called up from the form load event.????
    any ideas???




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