Emulate the QBE for Append Query (1 Viewer)

NauticalGent

Ignore List Poster Boy
Local time
Today, 02:40
Joined
Apr 27, 2015
Messages
6,341
Good morning everyone,

I have a situation where the input file format we receive changes periodically (column names, specifically). I discovered this when my saved import was putting the wrong data in the wrong columns.

I really want the user to be able to import the file, although it would be degree of job-security if I told them there was no way to achieve this unless I did it. My thought process on this would be to loop through both tables' fields and then populate a form that allows the user to match the import field to the destination field and then build the SQL statement from that.

Seems like a real PITA, but once it is done then that should be the extent of it. Before I went down that road, I wanted to ask you all your thoughts and maybe have a better solution...

Hit me...
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 02:40
Joined
May 21, 2018
Messages
8,529
Take a look at this demo. I think it is pretty close to allowing you to find matching fields and then map non matching.
 

NauticalGent

Ignore List Poster Boy
Local time
Today, 02:40
Joined
Apr 27, 2015
Messages
6,341
Take a look at this demo. I think it is pretty close to allowing you to find matching fields and then map non matching.
Thanks MajP, I am busier than a one-armed paperhanger right now but will take a look as soon as I get a chance...
 

sxschech

Registered User.
Local time
Yesterday, 23:40
Joined
Mar 2, 2010
Messages
793
Here is a demo of how to work with the QBE to graphically map fields for append queries. It is in a zip file that includes instructions on how to use.
 

Attachments

  • MapperExample_R01.zip
    341.5 KB · Views: 90

CJ_London

Super Moderator
Staff member
Local time
Today, 07:40
Joined
Feb 19, 2013
Messages
16,612
My thought process on this would be to loop through both tables' fields and then populate a form that allows the user to match the import field to the destination field and then build the SQL statement from that.
What I use is two listboxes each populated with a field list.

Select a field from each list and click a button. Code then inspects the tabledef field properties to ensure they match (integer to long OK, long to integer maybe not) Also checks the destination has not already been assigned a value. If OK then updates a simple list (another listbox) of fields matched.

When all done, I save the matches to a table and the query is then built on the fly when required.

edit: the other trick if it is just column headers that change and the order and number of columns doesn't, is to import without headers. You will then get default headers of F1, F2, F3 etc
 

Users who are viewing this thread

Top Bottom