How do you get a query to look at a query on another page, without having to copy that query and paste it in the page your working on

for example: ive the option of sending invoices manually and automatically and I have the image in the action page when I manually send them, without coping and pasting the code I need I want to ba able to reference abck to this, (it will same me having to update the same query twice if it needs to be changed down the line