SQL Server/Access Front End Need to create a checkout process on primary key (product_number)
Working with an Access front end/SQL Server backend (linked tables). Need to create process that will send a message to any user that tries to open the same product_number that is already checked out by another user at the same time.
Microsoft AccessSQL
Last Comment
ste5an
8/22/2022 - Mon
ste5an
First of all: While this is not a hard task, it is a complicate one. Cause what happens when a user forgets to check-in again?
But the solution is pretty simple: Use a store procedure for this. Something like
CREATE PROCEDURE CheckoutItem ( @ProductNumber INT, @UserName SYSNAME OUTPUT )AS SET NOCOUNT ON; SET XACT_ABORT ON; -- Constants. DECLARE @GENERIC_ERROR INT = -1; DECLARE @NO_ERROR INT = 0; BEGIN TRY INSERT INTO Checkout ( ProductNumber ) VALUES ( @ProductNumber ); RETURN @NO_ERROR; END TRY BEGIN CATCH SELECT @UserName = UserName FROM Checkout WHERE ProductNumber = @ProductNumber; RETURN @GENERIC_ERROR; END CATCH;
But the solution is pretty simple: Use a store procedure for this. Something like
Open in new window
with
Open in new window
and run this as pass-through query in Access to check-out your product.