Results 1 to 5 of 5

Thread: Could some one tell me what this does

  1. #1
    GingerFreak
    Guest

    Could some one tell me what this does

    VB Code:
    1. Found = False
    2.     If Dir(App.Path & "\Versions.mdb") <> "" Then
    3.         Set dbVersions = OpenDatabase(App.Path & "\Versions.mdb")
    4.     Else
    5.         Set dbVersions = CreateDatabase(App.Path & "\Versions.mdb", dbLangGeneral)
    6.     End If
    7.     For Each tblVersions In dbVersions.TableDefs 'This bit here
    8.         If tblVersions.Attributes = 0 And tblVersions.Name = "Stock" Then
    9.             Found = True
    10.             Exit For
    11.         End If
    12.     Next 'Too here
    13.     If Not Found Then Create.StockDatabase

    Couldn't I just do this

    VB Code:
    1. If Dir(App.Path & "\Versions.mdb") <> "" Then
    2.         Set dbVersions = OpenDatabase(App.Path & "\Versions.mdb")
    3.     Else
    4.         Set dbVersions = CreateDatabase(App.Path & "\Versions.mdb", dbLangGeneral)
    5. Create.stockdatabase
    6.     End If

  2. #2
    Lively Member nateobot's Avatar
    Join Date
    Feb 2002
    Location
    Minneapolis, Minnesota
    Posts
    71
    I **think** it is looking first to see if that Stock table exists. If it does not exist then it runs Create.StockDatabase

    Your code does not check for this table. It could be an important step in the rest of the code to check for this table.

  3. #3
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    It would a safe bet to keep that code there as it is possible for someone to open the database manually and delete the table.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  4. #4
    GingerFreak
    Guest
    Basicly if the database exists then the table will exist and if
    the database don't exist then the table wont exist so can I
    just cut that bit of code out

  5. #5
    GingerFreak
    Guest
    Good point Cander but my database has over 6 tables and I
    don't want to check all of them. Plus the system it will be on
    doesn't have any software to open a database. So do you think
    I need it

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