?
Solved

Creating Access Tables Via VBA

Posted on 2007-10-02
6
Medium Priority
?
252 Views
Last Modified: 2012-06-22
Hi

I am creating a table on the fly through VBA. Can anyone tell me how I would create the table with the requireed field set to NO on all records. My current code is;

With tbl1
            .Name = GapTitle & " - " & Date
            For j = 1 To NoOfControls
                FieldText = Me("Text" & j)
                .Columns.Append FieldText, adVarWChar, 30
            Next
        End With

Thanks
0
Comment
Question by:andyb7901
  • 4
  • 2
6 Comments
 
LVL 77

Accepted Solution

by:
peter57r earned 2000 total points
ID: 19998219
You will find the answer to this Q and many other code examples here:
http://allenbrowne.com/func-ADOX.html#CreateTableAdox
0
 

Author Comment

by:andyb7901
ID: 19998223
I have tried the following but with no luck;

        With tbl1
            .Name = GapTitle & " - " & Date
            For j = 1 To NoOfControls
                FieldText = Me("Text" & j)
                .Columns.Append FieldText, adVarWChar, 100
            Next
            For j = 1 To NoOfControls
                FieldText = Me("Text" & j)
                .Columns(FieldText).Properties("Required").Value = False
            Next
        End With
0
 

Author Comment

by:andyb7901
ID: 19998505
peter57r, your example does not have anything on the "Required" Field? If I do the following it works fine, but it needs the table to be created first?

   Set db = CurrentDb()
   Set tbl = db.TableDefs("tblDepartments")
   
   Set fld = tbl.Fields("Organization")
   tbl.Fields.Append fld
   fld.Properties("Required").Value = False
   fld.Properties("AllowZeroLength").Value = True
0
Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

 
LVL 77

Expert Comment

by:peter57r
ID: 19998634
peter57r, your example does not have anything on the "Required" Field

It certainly does.  Under the heading 'required field'!!
0
 

Author Comment

by:andyb7901
ID: 19998728
Do you mean this section;

        'Required field.
        With !Surname
            Set .ParentCatalog = cat
            .Properties("Nullable") = False         'Required.
            .Properties("Jet OLEDB:Allow Zero Length") = False
        End With

I have scanned the document for "Required" and this is what is baught back? If I have missed the section I am sorry, could you provide the section extraxt for me?
0
 

Author Comment

by:andyb7901
ID: 19999282
I have looked through the document and can not get anything to work? Anyone have any advise?
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Suggested Courses

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question