Auto populate field in new record

I have two tables, Owner (ownerid - prim key) and Vehicle (vehid - prim key).

I populate a grid of Vehicles based on owner (owner can have many vehicles). In the grid, I have a link to edit/add to the vehicle. In edit mode, the ownerid is displayed.

What I want to happen - is when I add a new vehicle, I want auto populate the new vehicle record ownerid for the one in the edit form.

Any suggestions on how to do this?

Found a solution - someone else’s fix - wish I could give credit to the person, can’t find source

# ---------------------------------------------------------------------------------------------------
# FORM - onLoad event - determine if in insert (new record) or update mode
# Can be used to prefill fields on a new record
#
# Tested with MySQL version 8.021 - worked fine on Ubuntu 20.04.3
# ---------------------------------------------------------------------------------------------------

if (empty({PRIMARY KEY})) {
** # INSERT mode - ASSIGN global/local variable to prefill a FIELD(s)**
}
else {
** # UPDATE mode**
}