Null values do not have text qualifiers around the fields in a standard,
delimited-text export of a table or query in Microsoft Access 2000.
An example of a line from an export of this type would be:
1,"abcde",,"fghij"
The two commas together show how a
Null value is exported if a comma
delimiter is chosen.
You can use one of two methods to place text qualifiers around
Null values
in a text export from a Microsoft Access table or query. Use
Method 1 if you do not require field names to be exported as the first
record of the text file. Use Method 2 if you do require field names as the
first record.
Method 1: Field Names Not Required in First Row
- Start Microsoft Access and open any database.
- In the Database window, click Tables, and then click New to create the following table:
Table: tblTest
FieldName: A
DataType: Text
FieldName: B
DataType: Text
FieldName: C
DataType: Text
Save the table as tblTest.
- Open the tblTest table and add the following records to the table:
Record Field A Field B Field C
--------------------------------------
1 data data data
2 data data
3 data data
4 data data data
- Close the tblTest table.
- In the Database window, click Queries, and then click New. In the New Query dialog box, click Design View, and then click OK.
- In the Show Table dialog box, click tblTest, click Add, and then click Close.
- Create the following fields in the query grid:
Field: Field A: Chr(34) & [A] & Chr(34)
Field: Field B: Chr(34) & [B] & Chr(34)
Field: Field C: Chr(34) & [C] & Chr(34)
- Save the query as qryExportTest.
- On the File menu, click Export.
- In the Export Query qryExportTest To dialog box, in the Save as type box, select Text Files.
Click the Save button to start the Export
Text Wizard.
- In the Export Text Wizard dialog box, click Next.
- On the next screen, set Text Qualifier to {none} and click Finish.
The text export is completed, and a message box is displayed stating
that the file was created successfully. Click the OK button.
- Open the text file in NotePad. Note that all fields have quotation
mark text qualifiers, including the Null fields.
Method 2: Field Names Required in First Row
- Start Microsoft Access and open any database.
- In the Database window, click Tables, and then click New to create the following table:
Table: tblTest
FieldName: A
DataType: Text
FieldName: B
DataType: Text
Default Value: =Chr$(32)
FieldName: C
DataType: Text
NOTE: The default value is set to a single blank space (Chr$(32)) in any field in which there might be a Null value. The field appears blank, but it is, in fact, not null.
Save the table as tblTest1.
- Open the tblTest1 table and add the following records to the table:
Record Field A Field B Field C
--------------------------------------
1 data data data
2 data data
3 data data
4 data data data
- On the File menu, click Export.
- In the Export Query qryExportTest As dialog box, in the Save as type box, select Text Files.
Click the Save button to start the Export
Text Wizard.
- In the Export Text Wizard dialog box, click Next.
- On the next screen, click to select Include Field Names on First
Row, and then click Finish. The text export is completed, and a
message box is displayed stating that the file was created
successfully. Click OK.
- Open the text file in NotePad. Note that all the fields have quotation marks at the beginning and the end.
- On the Edit menu, click Replace. In the Replace dialog box, in the
Find what box, type " "; in the Replace with box, type "", and then
click Replace All. Note that NotePad replaces any instance of " " with
"". Close the Replace dialog box. This step removes any default blank spaces which were used to force quotation marks to be inserted for Null text fields.
- Save the text file and quit NotePad. All Null fields now contain ""
text qualifiers.