New to Access

G

gary

I have Microsoft Access 2007 but I've never used Access before.
Because of the size of my files, Access has been suggested (rather
than Excel).

I have two files:

partnumber.txt has 2,500 records that look like this:
101110004
101110005
101110008
101110008
101110009
101110009
101110010
101110010


allpartnbrs.txt has 3 million records that look like this:
101110005121988101110013101110016
101110008011990101360001
101110008011990101360001101360010
101110009021991101110017
101110009021991101110017101110018
101110010101990101370002
101110010101990101370002101370034
101110010101990101370033
101110010101990101370033101370040
101110010101990101370033101370041
101110011121988101110014
101110011121988101110014101370001
101110011121988101110014101370003

Can someone walk me through each step to find the rows in
allpartnbrs.txt whose first 9-characters match the characters in
partnumber.txt?
 
A

Albert D. Kallal

Here is the general approach I would take:

first import the part number text table.

then import the allpart numbers text of table

I would then add a second field to the allpart numbers text table.
(lets call it PartNumPart)

I would then run an update query to pull the part number from the long
field.

fire up the query builder.

drop in your allpart number table into the query builder.

go tools->query->update query.

we just changed the query to an update query

for the first column, select partNumPart

in the update to field: put

left([partNum],0)

the but will result in the SQL query as:

update tblAllPartNumbers set PartNumPart = left([Partnum,9)

you can outrun this update query

the result will be a new column field with the actual just part number
(first 9 chars).

once you've built the above you can simply build a new query and match the
new column with the other table by a simple join.

you can then either print the query or build the report.

So we can do this whole process without having to build any code, but you'll
need some familiarity with the query builder.

Of course we'll do this on a backup copy of data as running update queries
can damage data really easily.
 
G

gary

All of the long records in the allpartnbrs.txt file are being
truncated in the Access database.

For example:

allpartnbrs.txt: 101110005121988101110013101110016
Access database: 101110005121988101110013

(The short records are OK).
 
A

Albert D. Kallal

I noticed in your example here you now have a bunch of spaces in front of
the actual data in the field.

In your original post you did not have such extra blank spaces in the data.

I would think we we should first of successfully import the data before we
talk about complex matching between the two tables.

Does the original data have those extra spaces on purpose? Do you want to
keep those extra spaces?

When you use the import wizard I would suggest that you consider selecting
fixed text format.

In fact you could use the import wizard and only accept the first nine
characters of the larger field data, and that way you could eliminate the
need for that additional step of the update query.


you have:

101110005121988101110013101110016
101110008011990101360001
101110008011990101360001101360010
101110009021991101110017
101110009021991101110017101110018
101110010101990101370002

looking at the above, is the above six records or only three records? Are
you looking to only take the first nine characters of each of the above
rows? (or or you looking to split out every nine characters into a separate
records?).

When you use the import wizard have you tried using fixed link for your
import?

The matching part of the data should be quite easy but we've not even gone
beyond the first step of successfully importing the data.

We'll need a bit more information here to figure out how the above data is
to be imported, it is not quite clear from what you have listed so far.

It's not even clear from the above six lines if we're talking about three
records on one line (due to wrap in the newsgroup reader).

Since the above data has no spaces and yet you claim when you import you do
have spaces then something is simply not correct, will have to fix this
problem before we tackle the second problem of matching the two tables.
 
G

gary

I got down to "you can outrun this update query" but how do I do that?

Also, how do I "simply build a new query and match the new column with
the other table by a simple join"?
 
G

gary

I got down to "you can outrun this update query" but how do I do that?

Also, how do I "simply build a new query and match the new column with
the other table by a simple join"?
 
A

Albert D. Kallal

gary said:
I got down to "you can outrun this update query" but how do I do that?


That was a typo that was munched by my spell checker; it should have read

"you can now run this update query"

Also, how do I "simply build a new query and match the new column with
the other table by a simple join"?


As I said this is 100% complete waste of time on your part and until you fix
the import problems you mentioned in your other post.

However to answer your question, you simply build a new query. You then
simply drop in both tables and and then draw a join line with the mouse by a
drag and drop between the two fields. When you view this query then you only
see matches in the two tables that are equal. So, this part is easy, the
hard part is getting your import correctly functioning.
 
G

gary

There are NO spaces in front of the data.
However, I deleted the first 20 or so records from the allpartnbrs.txt
file.
I then imported that file into Access and all of the records (long and
short) got imported.

Do your instructions apply to Access 2007? (They don't seem to be
accurate).

For example, in Access 2007:

There is no "query builder" but there is a "Query Design?"

There are no "tools>query>update query" selections

Does "drop in your allpart number table into the query builder" mean
the say thing as "put "left([partNum],9) in the first column, select
partNumPart?
 
A

Albert D. Kallal

gary said:
There are NO spaces in front of the data.

Yes I understand that there's no spaces in front of the data.

Your other post suggest that after you import the data, then you do have a
bunch of space in front.

However, I deleted the first 20 or so records from the allpartnbrs.txt
file.

Ah, ok, great, it sounds like you solved the blank character problem.
Do your instructions apply to Access 2007? (They don't seem to be
accurate).

For example, in Access 2007:

There is no "query builder" but there is a "Query Design?"

Sure you'll have to make a bit of assumptions here. query creator, query
builder, query designer, query system,
Sure they're all much the same terminology in this context.
Does "drop in your allpart number table into the query builder" mean
the say thing as "put "left([partNum],9) in the first column, select
partNumPart?

Are you talking about the query that matches the two tables or the query
that reads our field which is nine characters long, and creates a new
column?

As I mentioned we have two possible ways to solve this problem:

We can chop off the additional characters after 9 during the import process.
I think due to your skill level this would actually be a bit easier for you
than using the left("your text",9) function and building a query.

Either way is quite fine. Since it seems your import went OK then it is a
bit late to use the import feature to strip the extra characters. If what
follows is a little bit too difficult than perhaps you should try
reimporting the data again, and during the import have access strip out the
extra characters.

As the stands now we'll go with the second approach. The second suggestion
is thus to create a new field in table allpartnumbers that is only nine
characters long.

After we create this new field, we then run a query to update it with the
first nine characters from the larger field
(in effect will going to move the first nine characters from our origial one
column to another new column)

After we've accomplished this transfer process in this one table, we then
can we'll build and other new query in which we match both tables.

So, first let's open up the allpartnumbers table in design mode. (again I
don't know what your table names are so you have to do a bit of assuming
here).

When the database is open on the left side you should have a navigation
pain. from that left navigation pain you want to right click on your table
and select design.

Now, add a new column to the table. Give this new column name (or is what is
often referred to as a field name) any name you want. something descriptive
like shortpartnum will work just fine here.

For the data type setting use text.

Now close the table, you will be prompted to confirm you changes to the
table design.

this gives us our second column in the table. is this field/column in which
we will move the first nine characters from the first column this table.

thus we now create a new query.

(Click on create tab, and from the ribbin select query design)

At this point the query designer should be asking what table to use for this
query.

Select your table from the list and then click the close button on this
dialog prompt.

Now from the ribbion, You'll see something called query type. You want to
change this query to an update query (use your mouse cursor to hover over
the options - it is usually the second one from the last (Looks like a
little pencil beside an exclamation mark - select this option to change the
query to its update query).

when you choose this option you'll notice how the query grid changes and
adds a new row called

Update to:

So in the first column of the query builder you can use a combo box to
select the NEW field That made above to accept the nine characters of data.

We're going to take the first nine characters from that long data field and
into our newly created column.

It is in the update to row where we will enter expression with the left()
function.

it should look lik:

Update To: left([NameOf1stCollumWithData,9])

you can now run this query (In the ribbon, you'll see a result tab, and a
big ! mark called run. click on this to run).

at this point if this is been done correctly will have a new column with a
nine characters. you can now close this query we're done with it and
actually don't need it anymore.

now at this point are going to create a new query, the process is a similar
to the first time around. however this time we're going to drop in both
tables into the query grid. this is where we use the mouse to drop I join
line between the two fields in the two tables. We can this join line because
we now have a matching column in each table with which to match the data we
have.

asked you'd rather join line you can also pull a couple of fields from
either table into the query builder grid. when you run this query you'll get
matches between both tables.

The above all assumes that you import was correct and you've clearly read
and answered my other questions. The most important detail here is it safe
to assume that all the characters after the nine characters in that one big
column can be ignored? In other words is the data after the 1st name
characters you imported are not of importance?
 
Top