select max(id) from table1.
store result of query in any variable.
int id=result of query
Now if you want to insert data in both tables at the same time then
to insert id in second table you can use
now insert (id+1) for table2.
your table2 id column should not be auto increment.
hope it will helps you.
Note:This works in case of single user desktop application