Results 1 to 6 of 6

Thread: Need help on two questions please...

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Posts
    154

    Question

    Hi,

    In the following code below, I am loading the UserID's from my database into a combo box when the initial form loads at startup.

    '############################
    Private Sub Form_Load()
    Set db = OpenDatabase(App.Path + "\" + "test.mdb")
    Set rs = db.OpenRecordset("Users")

    rs.MoveFirst
    Do Until rs.EOF

    cmbUsers.AddItem rs.Fields("UserID")

    rs.MoveNext
    Loop

    db.Close
    End Sub
    '############################

    My first question is...

    How can I go ahead and load the form if the database is empty?


    My second question is...

    When I distribute my program, will I need to include the DAO360.DLL also?


    Thanks a lot,
    Ron

  2. #2
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    1) It should load anyway. Only the combo box won't have anything in it.

    2) Make a setup package with the Package and Deployment Wizard. This will automatically include any files your app needs to work properly.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Posts
    154
    Hey chrisjk,

    I get the following when I try to run it empty...

    Run-time error '3021':

    No current record.


    Any Suggestions?
    Thanks,
    Ron

  4. #4
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    I think I've spotted why. It's moving the record to the first, but can't because there are no records. Try this:
    Code:
    Dim intRecordCount As Long
    intRecordCount=rs.RecordCount
    
    If intRecordCount => 1 Then
     rs.MoveFirst 
     Do Until rs.EOF 
      cmbUsers.AddItem rs.Fields("UserID") 
      rs.MoveNext 
     Loop
    End If
    Hopefully that works!

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Posts
    154
    Hey chrisjk,

    That did it! I sure do appreciate your help.

    Have a good one, and thanks again,
    Ron

  6. #6
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923

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