Adding fields

D

Dodo2u

I'm running a MakeTableQuery (if that is the proper translation from
Dutch) to create a new table after export of a batch of ASCII-data from a
different application, which is linked to the database.
This replaces each time the table that was used before, which is a pity
because several fields have to be added to that table. So far this has
been done manually.

How can it be done in VB? I have added some lines to the button code to
get this done automatically, but I cannot find the proper expression for
a selection (tick?) box (selectievakje?).

So, something similar to:

DoCmd.OpenQuery "A5-A6_keuze"

Dim db As DAO.Database
Dim tbl As DAO.TableDef
Dim fld As Field
Dim fld2 As Field
Dim Veld5 As Field
Set db = CurrentDb
Set tbl = db!janus
Set fld = tbl.CreateField("A5", dbBoolean)
Set fld2 = tbl.CreateField("A6", dbBoolean)
tbl.Fields.Append fld
tbl.Fields.Append fld2

db.Close

This works but the Boolean type gives a 0 or 1, not a selection box (that
little square that you can tick).

Appreciate any help!
 
J

John Vinson

This works but the Boolean type gives a 0 or 1, not a selection box (that
little square that you can tick).

Two suggestions:

- Don't bother using table datasheets for data entry. They're not well
suited for that purpose. Use a Form; on the form you can use a
checkbox control bound to the Boolean field (or a textbox, or a combo
box, or...)

- Rather than running a MakeTable query and then patching up the table
afterward, consider creating a table with the needed fields; run a
Delete query to empty it followed by an Append query to load it with
the data from the textfile.

John W. Vinson[MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top