Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Posts
    254
    Thanks
    0
    Thanked 0 Times in 0 Posts

    cancel event if a table does not exist (Access 2000)

    I want to open a form from a control only if a table products exists in he database.Otherwise i want to give an warning message and cancel the event.I use the following function
    Dim db As DAO.Database
    Dim tdf As DAO.TableDef
    For Each tdf In db.TableDefs
    If tdf.Name = "products" Then
    DoCmd.SetWarnings False
    DoCmd.OpenForm "frmWarehouseUpdate", acNormal, "", "", , acNormal
    DoCmd.SetWarnings True
    Else
    End If
    Next tdf
    =============
    However i receive the message object or variable not set. Can somebody help me in building a similar code,possibly in ADO,with which to cancel the event in case the table products is not present?

  2. #2
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: cancel event if a table does not exist (Access 2000)

    Hi,
    You don't appear to have initialised the db object variable in your code. Try adding
    set db = currentdb
    after your second Dim statement.
    Hope that helps.
    Regards,
    Rory

    Microsoft MVP - Excel

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •