Results 1 to 6 of 6

Thread: [resolved] CREATE TABLE blues...

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    May 2005
    Posts
    530

    Resolved [resolved] CREATE TABLE blues...

    Hello,
    I'm trying to create a table using the CREATE TABLE command (in Access 2000) and I'm having great difficulty. First off, I need to say that any solution must be ADO, not DAO. Here's the statement I'm using...
    VB Code:
    1. CREATE TABLE tblFoundItems (ModelNumber TEXT, FxCap TEXT, FyCap TEXT, _
    2.         FzCap TEXT, MxCap TEXT, MyCap TEXT, MxCap TEXT);
    This is straight out of the Access 2000 Developer's Handbook, yet it gives a compile error. I don't see what is wrong with the statement, but I'm new to Access... (so go easy on me).
    Thanks
    Last edited by rickford66; Aug 19th, 2005 at 01:18 PM.

  2. #2
    Fanatic Member dannymking's Avatar
    Join Date
    Jul 2005
    Location
    Darlington, North East UK
    Posts
    677

    Re: CREATE TABLE blues...

    Neither ADO or DAO can accomplish this one..

    VB Code:
    1. CurrentDb.Execute "CREATE TABLE tblFoundItems (ModelNumber TEXT, FxCap TEXT, " & _
    2. "FyCap TEXT, FzCap TEXT, MxCap TEXT, MyCap TEXT)"

    There was a duplication in your query string on MxCap
    Danny

    Never Think Impossible

    If you find my answer helpful then please add to my reputation

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    May 2005
    Posts
    530

    Re: CREATE TABLE blues...

    Yes, that worked. I'm able to put data in the table no problem. The duplication was just an error do to copy/paste that I missed. Thanks for pointing it out. Now, I just have to ask one more question (I hope). When I'm finished using the table, I need to blow it away. How do I do that? Not just the connection to the table, but the table as well. I guess this is a 2 parter... before I create the table, I need to find out if it already exists... like, if it was created then the computer crapped out, it would leave the table in the DB and the program wouldn't work anymore. How can I check to see if it's there first?
    Thanks.
    Last edited by rickford66; Aug 19th, 2005 at 11:58 AM.

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    May 2005
    Posts
    530

    Re: CREATE TABLE blues...

    I found that...
    VB Code:
    1. CurrentDb.Execute "DROP TABLE tblFoundItems"
    seems to destroy the table.... so I just need to know how to check for its' existance.
    Thanks.

  5. #5
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: CREATE TABLE blues...

    Quote Originally Posted by dannymking
    Neither ADO or DAO can accomplish this one..

    VB Code:
    1. CurrentDb.Execute "CREATE TABLE tblFoundItems (ModelNumber TEXT, FxCap TEXT, " & _
    2. "FyCap TEXT, FzCap TEXT, MxCap TEXT, MyCap TEXT)"

    There was a duplication in your query string on MxCap
    BTW: ADO Can run such a query, through the command.execute method.

    Tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    May 2005
    Posts
    530

    Re: CREATE TABLE blues...

    Ok, got it... execute the following before I create the table
    VB Code:
    1. If CheckTableExists("tblFoundItems") = True Then
    2.         CurrentDb.Execute "DROP TABLE tblFoundItems"  'destroy the table
    3.     End If
    Then put this in a module...
    VB Code:
    1. Public Function CheckTableExists(strTableName) As Boolean
    2. On Error GoTo ProcessError
    3.     Dim rst As ADODB.Recordset
    4.     Set rst = New ADODB.Recordset
    5.     rst.Open strTableName, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
    6.     CheckTableExists = True
    7.     rst.Close
    8. EndCheckTableExists:
    9.     Set rst = Nothing
    10.     Exit Function
    11.  
    12. ProcessError:
    13.     CheckTableExists = False
    14.     GoTo EndCheckTableExists
    15. End Function
    Thanks for all your help. Now I can get some work done.

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