wrote:
Sorry to say that qryOCONT is a table three fields and one entry only
as
below
COCKEY
CODAT1
CODAT2
ORDER-EDI-OL
81869
Used
Each order that comes in gets the next number as it is processed and
the
table is updated +1
The EDI app is VB code that was written 10 years ago and has been jury
rigged, held together with duct tape, paper clips and bailing twine.
All
I
know is that it is stable and works great processing 1000's of lines
of
orders every day. I have a copy of the code on my laptop as a VB
project
and
as an exe file that runs. I know that id i an get these orders stuffed
into
the EDI tables from there all is well since I can run the 'process'
function
that stuffs them into our live app. I have tried this by entering
manually
the data and processing it.
M
Dear Maureen:
I haven't figured out yet how best to help you further at this
point.
Much head scratching going on.
OK, maybe start out sending me the SQL of qryOCONT (assuming that is
a
query). How is 'ocont' dimensioned? As a Recordset, yes?
Hope this gets us somewhere.
Tom Ellison
Microsoft Access MVP
Ellison Enterprises - Your One Stop IT Experts
On Tue, 23 Mar 2004 16:52:49 -0500, "Maureen"
<
[email protected]>
wrote:
This code is from a Visual Basic project the is not yet been made
into
an
exe file. The edi app is an exe program that sits running waiting
for
the
communication part to say "GO" There is no "Public Function" that I
can
see,
There is 100's or even 1,000's of lines of code in the project. I
can't
be
more help... it's rather greek to me.
M
Dear Maureen:
The code needs to be in a function. I'm thinking perhaps it is,
but
I'm not sure. You didn't show the context.
Is there a line of code saying Public Function somewhere just
above
what you quoted? Please quote everything from this point to End
Function. I'm hoping this is the situation.
So please quote more of it.
Tom Ellison
Microsoft Access MVP
Ellison Enterprises - Your One Stop IT Experts
On Mon, 22 Mar 2004 21:49:18 -0500, "Maureen"
<
[email protected]>
wrote:
Tom,
The current order number is part of the VB order processing code
and
looks
like this:
'Open AS400/OCONT
frmMain.Caption = "Opening Control File..."
Set ocont = db4.OpenRecordset("qryOCONT")
ocont.MoveFirst
'pick up current order number
frmMain.Caption = "Getting Order Control Number..."
orderstr = Trim(ocont("CODAT1"))
ordernum = Val(orderstr)
'Use as Order number
inheader.Edit
inheader("INORDN") = Trim(Str(ordernum))
inheader.Update
'update AS400/OCONT
frmMain.Caption = "Resetting Order Control
Number..."
If ocont("CODAT2") = "Used" Then
ocont.Edit
ocont("CODAT1") = Trim(Str(ordernum + 1))
ocont.Update
Else
ocont.Edit
ocont("CODAT2") = "Used"
ocont.Update
Not at all sure how to get this to be 'called' from a query?
M
If there is a function provided that assigns the "next order
number"
then start with a select query that provides the CustID and
PO,
adding
this column as a calculated function. In the Query Design
Grid,
for
Field, put in "OrderNumber: = FunctionName()" where
FunctionName
is
replaced by the name of the function that assigns an order
number.
I recommend using a scratch copy of the database while you
experiment
with this.
Do you get the ascending order numbers this way? Once you do,
change
the query to an append query, adding rows to your table of
orders.
Note that the 3 columns from this query must match the columns
in
the
orders table you're building, and that they must do so in
order.
Alternatively, you can do the work of associating the SELECT
query
columns with the table columns.
Let me know how you get along with this, OK?
Tom Ellison
Microsoft Access MVP
Ellison Enterprises - Your One Stop IT Experts
On Mon, 22 Mar 2004 20:54:33 -0500, "Maureen"
<
[email protected]>
wrote:
Tom,
Thanks for your reply. I have put off entering these just yet
since
we
will
not recieve the inventory to fill them until Friday... I have
until
Thursday
to come up with a way to stuff them in!
You are correct the combination CUSTID + PO are unique to an
order
whrn
they
change, a new order has started. I spent a few minutes
looking
at
what
I
have and see that it is easy to group into unique CUSTID + PO
combinations
to get the header records I need. I can not see how i can add
a
new
field
for each record that auto increments from a predefined start
(i.e.
start
at
88,000 for header record 1 header record 2 would be 88,001
and
so
on)
from
the completed header records I could match trhe unique CUSTID
+
PO
to
the
data and stuff in the footer records with the correct order#.
I
don't
know
how really to do this but it seems logical to me.
M
Dear Maureen:
Given that the Order Numbers are being assigned in code you
could
do
the same, perhaps calling the function that assigns the
order
number
from your insert query. But this is only a guess. Without
examining
what it is doing, that's the best I can do from here.
However, this assignment function would only be used once,
when
inserting a new header. The footer must then follow that
number
until
a new order is begin. Given your description of the
spreadsheet
data,
it isn't clear to me exactly how you can tell where one
order
ends
and
another starts. Is that based on CustID / PO? That is,
every
line
that is from the same customer and has the same PO is an
order.
I'm trying to get you a query based solution, founded on
just
using
the existing function that assigns order numbers.
Depending
on
your
answers to the above, it just might be possible.
Tom Ellison
Microsoft Access MVP
Ellison Enterprises - Your One Stop IT Experts
On Sun, 21 Mar 2004 15:23:02 -0500, "Maureen"
<
[email protected]>
wrote:
Tom the edi app has a table to issue order numbers. Each
order
that
comes
take the next number and resets it. I can see whats
happening
in
the
EDI
code but I am at a loss since I know very very little
about
VB
code. I
can
link to the table it is called qryOCONT (it is a table)
COCKEY CODAT1 CODAT2
ORDER-EDI-OL 81859 Used
I only need to get the CUSTID and PO to be put into
tblEDIHeader...
all
of
the other details will be added when it is processed it
gets
matched
with
the main Customer Table. The same is true for Product I
only
need
product
code and qty everything else gets dealt with when the EDI
app
stuffs
into
our order entry system. It also validates customer and
product
numbers
with
an e-mail to summarize any problems. The spreadsheet was
extracted
from
a
database to start and I am confident that the data is
clean
these
PO's
are
being transferred to us. I can see how the distinct will
look
after
creating a unique header for each order and how the footer
will
get
populated with all of the entries. The only issue is to
get
the
order
number
issued for each header and them match it with the
corresponding
footer
records. The relationship will be based on the CustID +
PO#
there
will
be
one OrderNumber (CODAT1) for each of these. perhaps the
header
records
could
be sequentially numbered and this number added to the last
Used
CODAT1.
After I import all of these I could then reset CODAT1 to
update
for
the
next
number. I have had to do this on one or two occasions when
the
EDI
app
crashed and the number did not update. It willnot allow
the
same
number
to
be used twice.
This all may be a little unorthodox, but if I can get this
info
stuffed
in I
can save hours manually entering almost 10,000 lines of
orders
Monday
AM!
M
Dear Maureen:
I think I can see roughly what you're after.
You probably have multiple instance of the set of
columns
from
which
you have a "Header" each with (potentially) a different
ProdCode
and
Qty. You should have only one "Header" per order, but
multiple
"lines" to each order. Is that the idea?
If you link these spreadsheets as tables, you could
create
the
Header
as follows:
SELECT DISTINCT XXX AS [Order#], CustID, Name, PO
FROM Spreadsheet
This is close to what is needed for your "header" except
that
I
don't
see from where you're going to get the Order#. Also, I
see
some
other
problems here:
- In a good database design, you would probably not have
Name.
There
would be a separate table giving Name based on CustID.
Doesn't
CustID
determine what Name should be?
- In the spreadsheet, where you have more than one line
for
each
order, there would be a mess whenever the CustID or PO
were
different
for two different lines within the same order. A
database
can
easily
constrain this with proper design, but your spreadsheet
won't
necessarily follow this rule in all cases.
For the Footer, you could use:
SELECT Order#, ProdCode, Qty
FROM Spreadsheet
In all the above, you will create a name for the
spreadsheet
when
yo
u
link it into Access. The name you create there should
be
substituted
in both queries above.
To create the customers table I recommended, use:
SELECT DISTINCT CustID, Name
FROM Spreadsheet
Again, there is a problem if any customer's name is
entered
in
more
than one way.
There are ways of detecting these problems, and even of
creating
solutions for them with minimal user intervention.
Tom Ellison
Microsoft Access MVP
Ellison Enterprises - Your One Stop IT Experts
On Sat, 20 Mar 2004 23:30:36 -0500, "Maureen"
<
[email protected]>
wrote:
Not sure if I should ask this in "query" but...
I have an excel sheet with
| CustID | Name | PO | ProdCode | Qty |
The single excel sheet has orders for over 1,000
customers
and
each
PO
has
8-10 products. I would like to stuff it into our EDI
tables
for
autmatic
processing into OrderEntry.
I need to "separate" & "stuff" in to EDItables as
follows:
tbl.EDIHeader has | Order# | CUSTID | Name | PO |
tbl.EDIFooter has | Order# | ProdCode | Qty |
Any pointers or code samples?
M