Try putting the code in the form's activate event.
Ok, I'm having a little trouble initializing the databasename property
for my data control.
I'm programming in VB 4.0 professional edition, I'm using a simple MDI
application format, and I'm using an Access 97 database.
Here's my setup so far:
I have a MDI parent when a menu bar. When the user clicks 'New' it loads
an instance of the child (code snippet)
dim newone as frmChild
Then it opens the MDI child form.
Ok, I need to specify the database name during runtime otherwise when i
compile it later, my program won't be able to find the database. So, I
have found out how to do that which is as follows:
data1.databasename = app.path & "\mydatabase.mdb"
Right now I have it set up so that in the initialize event for the CHILD
form it adds a new record to the database (data1.recordset.addnew). I
need to do it here otherwise I get other problems. So, I thought, I'll
put it right before the .addnew and everything will be fine. WRONG!
Ok, IF I hard code the databasename property into the data control and
run the program, it runs fine. HOORAY! :) HOWEVER, when I try to set it
during run time I get the following error when it is trying to add a new
Run time error '91'
Object Variable or With block variable not set.
I'm thinking that the data control isn't loaded yet which is why I can't
access its properties.... is that right? I'm just starting to program so
please be gentle. :)
Thanks for your help.
2. Memo > 255