|
-
Apr 20th, 2001, 04:36 PM
#1
Thread Starter
Addicted Member
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
-
Apr 20th, 2001, 05:20 PM
#2
PowerPoster
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.
-
Apr 20th, 2001, 05:55 PM
#3
Thread Starter
Addicted Member
Hey chrisjk,
I get the following when I try to run it empty...
Run-time error '3021':
No current record.
Any Suggestions?
Thanks,
Ron
-
Apr 20th, 2001, 06:22 PM
#4
PowerPoster
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!
-
Apr 20th, 2001, 06:54 PM
#5
Thread Starter
Addicted Member
Hey chrisjk,
That did it! I sure do appreciate your help.
Have a good one, and thanks again,
Ron
-
Apr 20th, 2001, 07:07 PM
#6
PowerPoster
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|