How do I specify a field type when importing a text file? (One)

zhaozj2021-02-16  55

How do I specify a field type when importing a text file? (One)

problem:

I have a text file to import Access, but a column of data is originally text, but the import database is automatically turned into a "double precision" type. How can I let each field generate according to the data type I need? How to let Access import data from text files, specifications from the architecture of I specified?

method one:

Access itself has an imported export wizard, which can be customized to import data in detail in the advanced option. The steps are as follows:

Menu -> File -> Get External Data -> Import (or "Link Table") -> Select You Required Format Document -> Advanced Menu -> File -> Get External Data -> Import (or "Link Table ") The picture is as follows: Choose the image you need to have the following: Click the" Advanced "button to the following: Define field specifications in Import Specifications, press" Save "button after the definition is complete, select the appropriate specification name As follows: Definition After the Field Specification is stored in MSYSIMEXCOLUMNS and the MSYSIMEXSPECS table below: After completing the above operation, you can use the following statement to link or import text files.

DOCMD.TRANSFERTEXT AclinkDelim, "List1 Import Specifications", "List1", "C: /List1.txt" DOCMD.TRANSFERTEXT ACIMPORTDELIM, "List1 Import Specifications", "List1", "C: /List1.txt" About TRANSFERTEXT method Refer to the following information (taken from Access XP Help)

TransferText Method In Visual Basic, the Transfertext method performs Transfertext operations. Expression.Transfertext (Transfertype, Specificationname, TableName, FileName, HasfieldNames, HTMLTABLENAME, CODEPAGE) Expression is required. Returns the expression of an object in the "Applies to" list. TRANSFERTYPE Optional ACTEXTTRANSFERTYPE. AcTextTransferType AcTextTransferType constants can be one of the following: acExportDelim acExportFixed acExportHTML acExportMerge acImportDelim default acImportFixed acImportHTML acLinkDelim acLinkFixed acLinkHTML If this parameter is blank, then the default constant (acImportDelim). Note You can link to the text file or the data in the HTML file, but the data is read-only in Microsoft Access. In the Microsoft Access project (Microsoft Access Project: Connect to the Microsoft SQL Server Database and use to create an Access file for the client / server application. There is no data or data-defined objects (such as tables or views) in the project file. ACIMPORTDELIM, AcimportFixed, AcexportDelim, AcexportFixed, or ACEXPORTMERGE conversion types are supported in .adp). SpecificationName Optional Variant type. String expressions (string expressions: any expression of a row of consecutive characters. Elements of expression can include: Returning string or string Variant (VARTYPE 8) function; string string value, constant, Variables or variant.), Indicating the names of imported or export specifications created and saved in the current database. For a fixed length text file, you must specify parameters or use the schema.ini file, which must be saved in the same folder of the imported, link, or export file file. To create a schema file, you can create this file using the Text Import / Export Wizard. For separate text files and Microsoft Word mail merge data files, this parameter can be left blank to select the default import / export specification. TableName Optional Variant type. String expression, indicating the name of the Microsoft Access table to import text data, export text data or link text data, or derived its results to Microsoft Access Query (Query: About the data stored in the table) Problem, or request to execute the data execution operation. The query can be placed together in multiple tables as a name of the data source.) From the data source.). FileName Optional Variant type. String expressions indicate the full name (including path) of the text file to be imported, exported or linked. HasfieldNames optional Variant type. Using true (-1) can use the first line of the text file as a field name when importing, exporting, or linked. Use false (0) to see the first line in the text file as normal data. If this parameter is left blank, the default value is used. This parameter will be ignored by Microsoft Word Mail Merge Data file, and the field name must be included in the first row of these files. HTMLTABLENAM optional Variant type.

String expressions, indicating the names of the table or list in the HTML file to import or link. This parameter will be ignored unless the Transfertype parameter is set to Ac1rthtml or AclinkHTML. If you leave this parameter, the first table or list in the HTML file is imported or linked. If there is a tag exists in the HTML file, the table or list name of the HTML file depends on the text specified by the tag. If there is no tag, the name is determined by the text of the tag. If there are multiple tables or lists with the same name, Microsoft Access will add a number to each table or the list name, such as "Employee 1" and "Employee 2" to distinguish them. CodePage optional VARIANT type. Long (Long Data Type: Store the basic data type of large integer .long variable is stored as a value of 32 digits, between 2,147,483,648 to 2, 147, 483, 647.) type value, the value of the code page is used to identify the code page. For more information on how this operation and how its parameters are used, see the subject of this operation. Optional parameters in the syntax allow for removal, but must contain a comma of the parameters. If you will leave the parameters on the end, you don't need to use a comma after the last parameter specified. Note By setting the ActiveConnection property of the Recordset object, you can also use the ActiveX Data Object (ADO) (Data Access Object (DAO): a data access interface, communication with Microsoft Jet, and communication with ODBC to connect, retrieve, and operate And update the data and database structure.) Create a link. Example The following example uses the specification "standard output", export data from the Microsoft Access table "External Report" to a text file with a separator: DOCMD.TRANSFERTEXT ACEXPORTDELIM, "Standard Output", _ "External report" , "C: /txtfiles/april.doc" http://www.access911.net webmaster collection</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-24505.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="24505" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.036</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'r1fllOsp8SSl_2FtWo6zTXAqYh8jcZVGYImR4NaGM_2FJzwexsOpL09QgzXdLKuA91dEfllYsXU03d27MCEF'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>