If(IsBlank(ItemDataCard),
//item does not exist, create the item
Set(varItem, Patch(Items, Defaults(Items), { 'Item Number': NewItemDataCardValue.Text, 'On Hand': Value(QuantityReceivedValue.Text) } ));
//create the receipt for the new item
Set(varReceipt, Patch('Item Receipts', Defaults('Item Receipts'), { Item: varItem, Location: LocationDataCardValue.Selected, Cabinet: CabinetDataCardValue.Selected, Bin: BinDataCardValue.Selected, 'Quantity Received': Value(QuantityReceivedValue.Text), Notes: NotesDataCardValue.Text } ))
,
//create the receipt for the existing item
Set(varReceipt, Patch('Item Receipts', Defaults('Item Receipts'), {Item: ItemDataCardValue.Selected, Location: LocationDataCardValue.Selected, Cabinet: CabinetDataCardValue.Selected, Bin: BinDataCardValue.Selected, 'Quantity Received': Value(QuantityReceivedValue.Text), Notes: NotesDataCardValue.Text }));
//update the total quantity on hand for the item received (if existing)
Patch(Items, ItemDataCardValue.Selected, { 'On Hand': varQuantityOnHand + Value(QuantityReceivedValue.Text) })
);
//update the receipt to completed
Patch('Item Receipts', varReceipt, { Status: 'Status (Item Receipts)'.Inactive, 'Status Reason': 'Status Reason (Item Receipts)'.Received });
ResetForm(frmAddItem);
Navigate(InventoryList,ScreenTransition.CoverRight);