
Cursor position in a module
Quote:
> How do I determine the module/procedure/line that my cursor is in?
I'm thinking that when any code is running, including the code that makes
this determination .... the "cursor" (I assume you mean the I-Beam insert/edit
cursor - not the DAO Workspace.DefaultCursorDriver related cursor) doesn't
exist. When no code is running, the cursor may or may not be in the source of a
code module. So (I'm guessing) the "cursor" can't exist in the same time-space
continuum as running code.
Quote:
> If you are interested in how I have approached this, below is the stuff I
> have tried but after playing for waaaay too long, I have determined that
> there must be an easier way!!!
> 1. use sendkeys to insert some text that will be used as a bookmark (make it
> unique by including the date and exact time)
I'm also assuming you're not talking about form or RecordSet Bookmarks......
Quote:
> 2. go through the modules collection and use the Find method to locate the
> text. There is a BIG problem here because the text doesn't want to actually
> be inserted until after the code has finished running ... i.e. until the
> Find that finished ... therefore the text is not found.
What if the cursor was in the module that was performing this check? In the
middle of a very important line. And you inserted some text (let's say a
comment) that effectively caused a syntax error in the line, or modified the
functionality of the line enough to cause other errors.
I think self-modifying code is silly and dangerous in *ANY* language (having
done my fair share of it), but in
VBA, yuck!
Quote:
> The workaround I
> have found, so far, involved opening a hidden form that does the sendkeys
> (On Open) and the sets the timer to run a function that searches for the
> text and sets some global variables. This works to a point, however there
> are still problems ... which brings me back to ... do you know a better way?
> Thanks,
> Dennis