K
Keith G Hicks
I need to have a SQL 2000 stored procedure pass an output parameter back to
my MS Access code. I've got the sp all set up but how do I execute it and
get the value back in vba?
I just need to pass a couple of parameters to the sp so that the select in
the sp will return the correct record and then I need to pass back a
particular field's value of that record.
Here's my sp so far:
CREATE PROCEDURE spE_GetAssetRec
@MoveDirection as char(1),
@UnitNum as Int,
@CatFilter as varchar(30),
@ReturnUnitNum as Int Output
AS
Set NoCount On
Declare
@Sql as varchar(8000)
If @CatFilter = ''
Select @CatFilter = ''
else
Select @CatFilter = ' And AssetCategoryCode = ''' + @CatFilter + ''''
If @MoveDirection = 'N'
begin
Select @Sql = 'Select Top 2 UnitNumber From tEAssets Where UnitNumber >= '
+ str(@UnitNum) + @CatFilter + ' Order By UnitNumber'
EXEC ( 'Declare Cur_Assets Insensitive cursor for ' + @Sql)
Open Cur_Assets
-- go to the NEXT unit number
Fetch Next from Cur_Assets INTO @ReturnUnitNum
-- Still need to account for end of file
end
--exec(@sql)
Return @ReturnUnitNum
Close Cur_Assets
Deallocate Cur_Assets
GO
Again, I just need code to run the sp from Acess and get the return value
into a variable in vba.
Thanks,
Keith
my MS Access code. I've got the sp all set up but how do I execute it and
get the value back in vba?
I just need to pass a couple of parameters to the sp so that the select in
the sp will return the correct record and then I need to pass back a
particular field's value of that record.
Here's my sp so far:
CREATE PROCEDURE spE_GetAssetRec
@MoveDirection as char(1),
@UnitNum as Int,
@CatFilter as varchar(30),
@ReturnUnitNum as Int Output
AS
Set NoCount On
Declare
@Sql as varchar(8000)
If @CatFilter = ''
Select @CatFilter = ''
else
Select @CatFilter = ' And AssetCategoryCode = ''' + @CatFilter + ''''
If @MoveDirection = 'N'
begin
Select @Sql = 'Select Top 2 UnitNumber From tEAssets Where UnitNumber >= '
+ str(@UnitNum) + @CatFilter + ' Order By UnitNumber'
EXEC ( 'Declare Cur_Assets Insensitive cursor for ' + @Sql)
Open Cur_Assets
-- go to the NEXT unit number
Fetch Next from Cur_Assets INTO @ReturnUnitNum
-- Still need to account for end of file
end
--exec(@sql)
Return @ReturnUnitNum
Close Cur_Assets
Deallocate Cur_Assets
GO
Again, I just need code to run the sp from Acess and get the return value
into a variable in vba.
Thanks,
Keith