In my experience, getting older requires that you also get more proficient in engaging with the passage of time. One of the things you do with your time is make decisions, and as your life unfolds the increasing number of decisions that lie in your past start to increasingly constrain your present and (what remains of) your future. Thats just how it is. People can tell you about this, but until you get there you don't
know it.
I don't know the OP, so I'm not going to address them in the first person, but I note that they don't say why they want to have children - only that they regret not having them. So I concur with others here that children might not be the main issue - but rather a proxy for general regrets and sorrow about the life changes that many people start to perceive in their fifth decade, as life becomes more constrained. I don't have good solutions for this, but living with regret is a hard road. I personally found the advice of the stoics useful here: don't try to control what you can't control, and the best way to deal with unhappiness over what you don't have is to try to be satisfied with what you do have. But I know thats easy to say and hard to put into practice. And it can lead you into the trap of inaction.
But I may be wrong. Some people just have a deep need to have children, ans this often transcends "reasons". While many societies see this as normal in women, we perhaps don't talk enough about how men can feel this way too. If this is genuinely the case for the OP then more therapy may be the only way to address it.
It's also worth them considering that actually having children might not address their present regret. I'm a guy in my mid fifties and I did have children (who are now on the edge of adulthood). Being a parent often was, and often still is, a immense joy. But it was also immensely hard in ways I can't adequately describe to people who haven't also done it. Again, until you get there you don't know. So its healthy to not romanticise parenthood and, for the OP, reflecting on whether this is the case for them may be an approach to take. Not easy though, but maybe easier than the alternative.
A couple of practical points. Physically, 40 and 38 is not too late (modulo any health issue) to conceive if the OP and his partner both want that. Its important to be aware of the risks of later parenthood, but very many people do have children at that point in their life. It is also important to be aware of the considerable strain it can put on a relationship. Give some thought to the financial implications too: its a heavy twenty-plus year commitment that will close-off some opportunities, and the cost of post-school education may come along just as you are starting to consider retirement.
We only get one life and I have no good answers. To the OP - I hope you find peace, however it goes for you.