Results 1 to 2 of 2

Thread: Can't Create Database in RunTime

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2000
    Location
    Netherlands Antilles
    Posts
    66
    Hi,

    I have been trying to create a database file during runtime. and i keep getting an error message "Argument not optional"


    this is the coding i am trying to use.
    Can anyone help me with this?

    Thanks in advance.
    EL.

    Public DbFile As Database
    Public RstFile As Recordset
    Public FileName As String
    Public TblFile As TableDef
    Public IdxFile As Index
    Public FLD As Field
    Public WrkDefault As Workspace
    Public DbsNew As Database

    Public Sub CreateDatabase()
    FileName = App.Path & "\database.mdb"
    If Dir(FileName) <> "" Then
    'open database file
    Set DbsNew = OpenDatabase(FileName)
    Set RstFile = DbFile.OpenRecordset("Recordset")
    Else
    Set WrkDefault = DBEngine.Workspaces(0)
    Set DbsNew = CreateDatabase(FileName) ' create data file
    Set DbsNew = WrkDefault.CreateDatabase(FileName)
    Set TblFile = DbFile.CreateTableDef("Recordset") ' create recordset
    With TblFile
    .Fields.Append .CreateField("FieldName", dbText, 10)
    DbFile.TableDefs.Append TblFile
    End With
    Set IdxFile = TblFile.CreateIndex("IdxFile")
    Set FLD = IdxFile.CreateField("Fieldname")
    With IdxFile
    .Primary = True
    .Unique = True
    .Required = True
    End With
    IdxFile.Fields.Append FLD
    TblFile.Indexes.Append IdxFile
    DbFile.Close
    End If
    End Sub

  2. #2
    Member
    Join Date
    Aug 2000
    Posts
    60
    In your createdatabase method you have to specify the locale information. If you're not sure which to use there is a general one. Here is an example.

    Set DbsNew = CreateDatabase(FileName, dbLangGeneral)

    That should solve your problem.
    Barend
    JHB-SA

    Nothing is impossible, except skiing through a revolving door.

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