Currently you select the transaction type ie transfer_out or transfer_in and add the record.
I would like to have the following happening simultaneously
If clinic A supply stock to clinic B then Clinic A = Transfer _out and Clinic B = Transfer_In for the same item, transaction date, etc etc and not 2 separate records to be added by the datacapturer.
This is the VBA that i currently use for 1 record added at a time. In the background i will then add or subtract stock accordingly for stock on hand calculations.
The "ID" of transfer_out is 3 and "transfer_in" = 4 and the other "id" transact should be "else"
I imagine the following has to be worked into the code:
Expand|Select|Wrap|Line Numbers
- if me.transact = "3" then run the code below and repeat the code using me.transact = 4 else "run only the code below once for me.transact that are not equal to 3 or 4 and also add the edit funtion".
Expand|Select|Wrap|Line Numbers
- Dim MyDB As DAO.Database
- Dim rst As DAO.Recordset
- Dim strSql As String
- Set MyDB = CurrentDb
- strSql = "SELECT * FROM Fis_CaptDataT WHERE [DataId] = " & Me![DataID]
- 'See if the Data has already been Captured, if not, Add, not Edit the Record
- If DCount("*", "Fis_CaptDataT", "[DataId] = " & Me![DataID]) = 0 Then 'NOT Captured/ADD
- Set rst = MyDB.OpenRecordset("Fis_CaptDataT", dbOpenDynaset, dbAppendOnly)
- With rst
- .AddNew
- ![Client_lookup] = Me![Client_lookup]
- ![InvoiceDate] = Me![InvoiceDate]
- ![ExpiryDate] = Me![ExpiryDate]
- ![Item_Lookup] = Me![Item_Lookup]
- '![CPrice] = Me![Price]
- ![CPrice] = Me![CPrice]
- ![Providers] = Me![Providers]
- ![Supplier] = Me![Supplier]
- ![Order_No] = Me![Order_No]
- ![Transact] = Me![Transact]
- ![BatchNo] = Me![BatchNo]
- .Fields("Transaction" & CStr(Me![Transaction])) = Me![InvoiceQty]
- .update
- End With
- Else 'Data Captured, so Edit the Recordset
- Set rst = MyDB.OpenRecordset(strSql, dbOpenDynaset)
- With rst
- .Edit
- ![Client_lookup] = Me![Client_lookup]
- ![InvoiceDate] = Me![InvoiceDate]
- ![ExpiryDate] = Me![ExpiryDate]
- ![Item_Lookup] = Me![Item_Lookup]
- '![CPrice] = Me![Price]
- ![CPrice] = Me![CPrice]
- ![Providers] = Me![Providers]
- ![Supplier] = Me![Supplier]
- ![Order_No] = Me![Order_No]
- ![Transact] = Me![Transact]
- ![BatchNo] = Me![BatchNo]
- .Fields("Transaction" & CStr(Me![Transaction])) = Me![InvoiceQty]
- .update
- End With
- End If
- rst.close
- Set rst = Nothing
- Set MyDB = Nothing
- If [Forms]![CaptureF]![finditem2].Value = "-1" Then
- DoCmd.GoToControl ("finditem")
- End If