so you have a function GetUserId, returning a long number - the top line of your function
if you already have an id, GetUserUd returns the Id, but you never set ID to a value, so this won't work.
if you don't have an ID, it opens "LoginForm" in dialog mode, so before your program can carry on, the LoginForm must close first. That's what acDialog does.
You then try to set GetUserID to a value on the "LoginForm", but because that form is no longer open, this must give you a run time error.
You appear to be mixing up a few things in the way you are trying to use your login form, so it isn't working in quite the way you want.