My Assistant
![]() ![]() |
|
|
Apr 13 2012, 08:55 PM
Post
#1
|
|
|
UtterAccess Guru Posts: 667 From: Singapore |
Hi experts out there.
I've a Sales Order ID which is an autonumber. I convert this Sales Order to a Delivery Order many times. [One to Many] because of Partial Orders. The first time I append, only one Delievry Order is created, but at the second time I append, two identical Delivery Orders are created. How to stop this duplication? Can I create a suffix to the autonumber with a increment number, so the append query transfer only the latest Sales Order over. and marked the sales Order [DOconvert] "yes" so the next time the append query will not append any Sales Orders with a "Yes" Any help is very much appreciated. |
|
|
|
Apr 13 2012, 09:09 PM
Post
#2
|
|
|
UA Admin Posts: 19,211 From: Newcastle, WA |
Actually you need a DeliveryID for the Delivery table. That will be unique.
In the Delivery table, your SalesOrderID is a Foreign key back to the Sales Order table. |
|
|
|
Apr 14 2012, 08:32 AM
Post
#3
|
|
|
UtterAccess Guru Posts: 667 From: Singapore |
Yes, I have a relationship between Sales Order and the Delivery Order. I have a DeliveryID in the Sales Order and a SalesOrderID in the Delivery Order.
|
|
|
|
Apr 14 2012, 03:58 PM
Post
#4
|
|
|
UtterAccess Veteran Posts: 303 From: Edmonton, Alberta, Canada |
Not sure I understand your setup here:
QUOTE I have a DeliveryID in the Sales Order and a SalesOrderID in the Delivery Order Because you have a one to many relationship, you only need a SalesOrderID in the Sales table, but you need both a DeliveryID and SalesOrderID (Foreign Key) in the Delivery table. What does your Append query look like right now? |
|
|
|
Apr 16 2012, 11:35 PM
Post
#5
|
|
|
UtterAccess Guru Posts: 667 From: Singapore |
Hi Darnellk, thanks for your help. I found this codes shown below. How do you modify the to suit my usage.?
I want only the [CODOConvertID] to increment by 1, but it does a total increment of all the forms. Me!CODOConvertID = Nz(DMax("[CODOConvertID]", "tblConfirmation", "ConfirmID = forms!frmConfirmation!ConfirmID"), 0) + 1 Much appreciate you help. |
|
|
|
Apr 17 2012, 02:21 PM
Post
#6
|
|
|
UtterAccess Veteran Posts: 303 From: Edmonton, Alberta, Canada |
This is quite a bit different than your first question, and may need its own topic depending on what you are looking for. I don't understand if the question you're asking now is related to the first one or not, and it is not clear to me what you're asking.
Is this your code or an example you found that you are trying to adapt to your situation? CODE Me!CODOConvertID = Nz(DMax("[CODOConvertID]", "tblConfirmation", "ConfirmID = forms!frmConfirmation!ConfirmID"), 0) + 1 Please try explaining what you want accomplished a little more. |
|
|
|
Apr 19 2012, 01:54 AM
Post
#7
|
|
|
UtterAccess Guru Posts: 667 From: Singapore |
Yes, it is a sample which I like to adopt. Thanks for your patience with me. I have a Sales Order with an autonumber. The Sales Order can be converted to many Delivery Orders.
I just want another "autonumber" in the Sales Order to keep count how many times the Sales Order has been converted to Delivery Order. This is to prevent duplicates. I activate the codes at the [Convert to DO] Icon - OnClick Event. Pleas ehelp |
|
|
|
Apr 19 2012, 11:32 AM
Post
#8
|
|
|
UtterAccess Veteran Posts: 303 From: Edmonton, Alberta, Canada |
What George and I were suggesting is something like the following:
tblSalesOrder SalesOrderID (autonumber) SalesOrder Customer (may be an ID number linked to a Customer table) SalesDate etc. tblDeliveryOder DeliveryOrderID (autonumber) SalesOrderID (number - relationship linked to tblSalesOrder.SalesOrderID which is a Foreign Key) DeliveryMethod DeliveryDate etc. I think I see what you're asking now, and the way I could see doing what you want is this: tblSalesOrderDelivery SalesOrderDeliveryID (autonumber) SalesOrderNumber (on click of new Sales Order this would be automatically numbered) DeliveryNumber (on click of new Delivery Number this would be automatically numbered) etc. The expression you posted should work and would look like this: A "New Sales Order" button on your form would have a click event as follows: CODE Private Sub cmdNewSalesOrder_Click() ' go to new record DoCmd.RunCommand acCmdRecordsGoToNew ' generate new Sales Order number Me!SalesOrderNumber = Nz(DMax("SalesOrderNumber", "tblSalesOrderDelivery"), 0) + 1 End Sub A "New Delivery" button on your form would have a click event as follows: CODE Private Sub cmdNewDelivery_Click() Dim lngSalesOrderNumber As Long ' get sales order number of existing record lngSalesOrderNumber = Me!SalesOrderNumber ' go to new record DoCmd.RunCommand acCmdRecordsGoToNew ' copy previous sales order number to the new record Me!SalesOrderNumber = lngSalesOrderNumber ' generate new Delivery number Me!DeliveryNumber = Nz(DMax("DeliveryNumber", "tblSalesOrderDelivery", "SalesOrderNumber = " & lngSalesOrderNumber), 0) + 1 End Sub |
|
|
|
Apr 20 2012, 04:08 AM
Post
#9
|
|
|
UtterAccess Guru Posts: 667 From: Singapore |
Wow, wow guys this is fantastic. Thats what I want, right at target. Thanks so much.
|
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 18th May 2013 - 01:33 PM |