Sure, you can have values in a temporary buffer, but it’s irrelevant if you don’t pass it to the query.
I suspect you don’t understand what temporary tables are. Let me give you an example.
// Put a record to TmpFrmVirtual
TmpFrmVirtual tmp1;
tmp1.Id = 'Test';
tmp1.insert();
// Getting the record we've just inserted
TmpFrmVirtual tmp2;
select tmp2
where tmp2.Id == 'Test';
We insert a record and try to read it, but we won’t find it. The reason is that there are two completely independent temporary buffers. We inserted the record to tmp1, while tmp2 is empty. Querying tmp2 can’t give you records that you put to tmp1.
Imagine that we’re working with Excel files. You write a value to A.xlsx and then you open B.xlsx and expect to find the same data there. It’s clearly not how it works.
And this is what happens with your query. You may have data in a buffer, but if you don’t say the query to run against it, it’ll query a new, empty buffer (like B.xlsx).
Do you know see why your code can’t work?
If so, it’s time to fix it. Call qr.setRecord() and use the buffer to which you’ve inserted the data as the parameter.