Error 91 Object variable or With-Block, variable not set 
Author Message
 Error 91 Object variable or With-Block, variable not set

Whenever my program executes the code marked 'create database in a sub
routine.  I get a run time Error 91 Object variable or With-Block, variable
not set  The sub routine is has follows.

Sub NewDatabase()
'define variables
Dim dbPeriod As Database
Dim wsPeriod As Workspace
Dim tdData As TableDef
Dim dfStartDate As Field
Dim dfEndDate As Field
Dim dfMonth As Field

'create database
Set dbPeriod = wsPeriod.CreateDatabase(dbLangGeneral, FileName)

'setup tables
Set tdData = dbPeriod.CreateTableDef("Period_Data")

'setup fields
Set dfStartDate = tdData.CreateField("Start_Date", dbDate)
Set dfEndDate = tdData.CreateField("End_Date", dbDate)
Set dfMonth = tdData.CreateField("Month", dbChar, 2)

'enable calculate menu
mnuCalculate.Enabled = True
End Sub

FileName is defined via the code Public FileName as String in the
declarations section of frm.Startup where this sub routine is located and is
filled via code in the cmdOk_Click sub routine of frm.FileOps (Provides the
visuals needed to get a new or existing file name from the user.).

I have an unbound data control on my form to manipulate a created database
or an existing one which I thought would provide the necessary libraries to
create a database.  I tried selecting Microsoft Access 8.0 Object Library in
the reference dialog, but that did not help.

My program is to provide a new database function which will create .mdb file
of a predefined structure using a user supplied file name and an open
database function to bind a user selected .mdb to a data control.

To see the calculations this program does get the old SDI version (new will
be MDI) by downloading www.cpacfo.com/lila/files/pc.zip.



Mon, 21 May 2001 03:00:00 GMT  
 Error 91 Object variable or With-Block, variable not set
I am sure but I think it is because you have not create a workspace
explicitly. Hopefully that will help.


Tue, 22 May 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Runtime error 91/Object variable or With block variable not set problems

2. runtime error: 91 Object variable or with block variable not set

3. Run Time Error 91: Object variable or With Block variable not set

4. VB 5.0 - Error:91 Object Variable Or With Block Variable Not Set

5. Object variable or With block variable not set (Error 91)

6. error 91 Object Variable o on with block variable is not set

7. Object variable or With block variable not set (Error 91) Please Help

8. Object variable or With block variable not set (Error 91)

9. Error 91-Object or block with variable not set

10. error 91 - object or block with variable not set

11. Debugging COM+ Componets -- Runtime error 91- Object variable or with block not set

12. Error 91 - object or block width variable not set

 

 
Powered by phpBB® Forum Software