As pointed out you can use a PT query, but such a query can't use a function from Access if the value is coming from each row, and you need the function for each row.
However, it not clear why a PT query is required?
The other solution would be to re-write the VBA function as a T-SQL function. So called "scaler" functions work just like VBA, but are server side, and written in T-SQL. Given that T-SQL has looping and just about every feature that VBA has, then once you re-write the code as T-SQL then your PT QUERY becomes this:
UPDATE tblEmp SET tblEmp.EmpName1 = dbo.Encrypt([tblEmp].[EmpName])
In the past, I had a global GST function written in VBA that would return GST rate (based on current date, so:
SELECT id, CompanyName, invoiceNumber, InvoiceDate, GST(InvoiceDate) as GSTRate
FROM tblInvoices
So, I simply re-write the GST() function (VBA) as a T-SQL function. This allowed easy conversion of Access SQL to T-SQL. So views, or even PT quires now could be sent to the server. The so called T-SQL scaler functions work just like when you write a global VBA function. Once written then such functions can be used in ANY SQL expression and any t-sql sql or even t-sql code you write.
So, my suggestion would be to re-write your encrypt VBA function as t-sql. Note that I looked high and dry for a means to NOT have to prefix such scaler functions with dbo.FunctionName (so you do have to use dbo.FunctionName ).
However, for complex quires, or even creating server side views,it is STILL rather nice to take Access SQL and convert it to t-sql - and the GST function or whatever function (such as your encrypt() function becomes dbo.Encrypt().
The beauty here is then you get the same freedom to use that function in ANY sql you write - and that now includes server side SQL.
So, during Access to SQL (back end) conversion projects, to save lots of time, and to save having to re-write SQL, by adopting the user of "scalier" t-sql custom functions, then you can enjoy the same development approach in t-sql as Access VBA developers (that approach being writing custom functions that you are then freely able to use in any SQL you write).
In fact, I had a ton of sql (not mine) that used:
SELECT id, CDBL(StockPrice) as StockP from tblPrices
The previous designer has some values stored as text columns. So, I created a scaler t-sql function like this:
ALTER FUNCTION [dbo].[CDBL]
(
-- Add the parameters for the function here
@P1 sql_variant
)
RETURNS float
AS
BEGIN
-- Declare the return variable here
DECLARE @Result float
-- Add the T-SQL statements to compute the return value here
SET @Result = CAST(@P1 as float)
-- Return the result of the function
RETURN @Result
END
After writing the above, then:
SELECT id, dbo.CDBL(StockPrice) as StockP from tblPrices
So, I would suggest you re-write the VBA code in t-sql. T-sql has just about every feature that VBA has, so I never come across VBA code that I could not re-create server side in the t-sql programming language. So t-sql functions work just like VBA ones in that once written you can freely use such custom functions in any other code, and even in sql queries that you write.