To store Send time context, you will need to store the values at send time inside an external DE that you use to lookup your values from in VAWP context.
What you are currently doing is not working because the VAWP link will always rerun the AMPscript at time that the page is loaded, based on the data in the source DE. This also means that if the source DE is cleared or that record is removed from that DE - then the VAWP will break.
By having an upsert in the email to place all your variables into a DE, you can then utilize those for VAWP via _MessageContext
similar to what you have here.
upsertDE("VAWP_Log", 2, "JobID",JobID,"SubscriberID",SubscriberID,"VarNames",@VarNames,"VarValues",@VarValues)
To make this as open ended as possible as each email could require different variables names and data types, I create 2 DE fields: 'VarNames' and 'VarValues' and then push these in as column delimited fields.
e.g.
SET @VarNames = 'FirstName|LastName|Title'
SET @VarValues = 'Don|Juan|Mr.'
you can then push this into your VAWP DE using an upsert.
the VarNames would have to be completely manual, but as the values are usually unique per individual, you would need to do:
SET @VarNames = "FirstName|LastName|Title"
SET @VarValues = Concat( @FirstName, '|', @LastName, '|', @Title)
Then inside your email you would utilize:
%%[
var @SendLogData, @SubLookup, @JobLookup
Set @SubLookup = SubscriberID
Set @JobLookup = JobID
Set @VAWPData = lookuporderedrows("VAWP_Log",1,"JobID ASC","SubID",@SubLookup,"JobID",@JobLookup)
if _MessageContext == "VAWP" then
if rowcount(@VAWPdata)>0 then
set @Row = Row(@VAWPData,1)
set @VarNames = BuildRowsetFromString(Field(@Row,"VarNames"),'|')
set @VarValues = BuildRowsetFromString(Field(@Row,"VarValues"),'|')
FOR @i = 1 TO RowCount(@VarNames) DO
SET @VarNameRow = Row(@VarNames,@i)
SET @VarValuesRow = Row(@VarValues,@i)
SET @tempName = Field(@VarNameRow,1)
SET @tempValue = Field(@VarValuesRow,1)
SET @FieldSet = TreatAsContent(CONCAT('%','%[SET @',@tempName, ' = ',@tempValue,']%', '%'))
NEXT @i
ENDIF
ELSE
/* Your Normal Var setting process */
ENDIF ]%%
This would then dynamically set your Variables via the two delimited fields via the BuildRowsetFromString
ampscript function.
example output:
SET @FirstName = "Don"
SET @LastName = "Juan"
SET @Title = "Mr."
As a note, I would push the upsert to the end of your ELSE
statement (which is the email part and I would make sure it only goes out in SEND context and not on TestSends to make your log as clean as possible.