custom field numbering sequence

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I have a Load Details table that looks like this:
OrderID
pk LoadID
ShipperID
Status

The LoadID's for each order always correspond to the OrderID and are
followed by a - then the sequential number.
Example: the first 3 loads for OrderID number 54321 are as follows:
54321-1
54321-2
54321-3
Is there anyway to automate this process, so that everytime a new record is
created, the LoadID is generated based on the OrderID it belongs to and the
previous LoadID's which exist in that order.

Thanks,
Justin
 
Create a query based on the table that take the LoadID and breaks it into to
fields
Order Number and counter

Select Cdbl(mid([FieldName],instr([FieldName],"-")+1) as MyCount,
Left([FieldName],instr([FieldName],"-")-1) as OrderId From TableName

On the After update event of the OrderId insert the code
Me.LoadIdFieldName = Dmax("MyCount","QueryName","OrderId = '" &
cstr(Me.OrderIdFieldName) & "'")
 
In the query I missed one thing
Select Cdbl(mid([FieldName],instr([FieldName],"-")+1)) as MyCount,
Left([FieldName],instr([FieldName],"-")-1) as OrderId From TableName
 
The SQL code looks like this:
Select Cdbl(mid([LoadID],instr([OrderID],"-")+1)) as MyCount,
Left([LoadID],instr([OrderID],"-")-1) as OrderID From [Load Details]

When I View it gives me "Circular reference caused by alias "OrderID" in
query definition's SELECT list."


Thanks for the help,
Justin

Ofer said:
In the query I missed one thing
Select Cdbl(mid([FieldName],instr([FieldName],"-")+1)) as MyCount,
Left([FieldName],instr([FieldName],"-")-1) as OrderId From TableName


--
In God We Trust - Everything Else We Test


Jae Hood said:
Hi,
I have a Load Details table that looks like this:
OrderID
pk LoadID
ShipperID
Status

The LoadID's for each order always correspond to the OrderID and are
followed by a - then the sequential number.
Example: the first 3 loads for OrderID number 54321 are as follows:
54321-1
54321-2
54321-3
Is there anyway to automate this process, so that everytime a new record is
created, the LoadID is generated based on the OrderID it belongs to and the
previous LoadID's which exist in that order.

Thanks,
Justin
 
Try this

Select Cdbl(mid([LoadID],instr([LoadID],"-")+1)) as MyCount,
Left([LoadID],instr([LoadID],"-")-1) as OrderID From [Load Details]

Replace the OrderID with LoadID in the sql

--
In God We Trust - Everything Else We Test


Jae Hood said:
The SQL code looks like this:
Select Cdbl(mid([LoadID],instr([OrderID],"-")+1)) as MyCount,
Left([LoadID],instr([OrderID],"-")-1) as OrderID From [Load Details]

When I View it gives me "Circular reference caused by alias "OrderID" in
query definition's SELECT list."


Thanks for the help,
Justin

Ofer said:
In the query I missed one thing
Select Cdbl(mid([FieldName],instr([FieldName],"-")+1)) as MyCount,
Left([FieldName],instr([FieldName],"-")-1) as OrderId From TableName


--
In God We Trust - Everything Else We Test


Jae Hood said:
Hi,
I have a Load Details table that looks like this:
OrderID
pk LoadID
ShipperID
Status

The LoadID's for each order always correspond to the OrderID and are
followed by a - then the sequential number.
Example: the first 3 loads for OrderID number 54321 are as follows:
54321-1
54321-2
54321-3
Is there anyway to automate this process, so that everytime a new record is
created, the LoadID is generated based on the OrderID it belongs to and the
previous LoadID's which exist in that order.

Thanks,
Justin
 
Perfect!

Thank you Ofer!

Ofer said:
Try this

Select Cdbl(mid([LoadID],instr([LoadID],"-")+1)) as MyCount,
Left([LoadID],instr([LoadID],"-")-1) as OrderID From [Load Details]

Replace the OrderID with LoadID in the sql

--
In God We Trust - Everything Else We Test


Jae Hood said:
The SQL code looks like this:
Select Cdbl(mid([LoadID],instr([OrderID],"-")+1)) as MyCount,
Left([LoadID],instr([OrderID],"-")-1) as OrderID From [Load Details]

When I View it gives me "Circular reference caused by alias "OrderID" in
query definition's SELECT list."


Thanks for the help,
Justin

Ofer said:
In the query I missed one thing
Select Cdbl(mid([FieldName],instr([FieldName],"-")+1)) as MyCount,
Left([FieldName],instr([FieldName],"-")-1) as OrderId From TableName


--
In God We Trust - Everything Else We Test


:

Hi,
I have a Load Details table that looks like this:
OrderID
pk LoadID
ShipperID
Status

The LoadID's for each order always correspond to the OrderID and are
followed by a - then the sequential number.
Example: the first 3 loads for OrderID number 54321 are as follows:
54321-1
54321-2
54321-3
Is there anyway to automate this process, so that everytime a new record is
created, the LoadID is generated based on the OrderID it belongs to and the
previous LoadID's which exist in that order.

Thanks,
Justin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top