Retrieve name of selected object in database window

SforSoftware

(NL) SnelStart specialist
Local time
Today, 03:15
Joined
Aug 16, 2003
Messages
239
Hi,

Is there any way to retrieve the name of the currently selected object in the database-window from code?

For selecting an object we can use docmd.selectobject with the third parameter on 'true', but i want the way back.

Thanks in advance,
Bert
 
SforSoftware said:
Hi,

Is there any way to retrieve the name of the currently selected object in the database-window from code?

For selecting an object we can use docmd.selectobject with the third parameter on 'true', but i want the way back.

Thanks in advance,
Bert

Hi Bert,

Something like:

Dim myControl As Control

Set myControl = Screen.ActiveControl
MsgBox myControl.Name

Set myControl = Nothing
 
Hi,

thanx for your answer.
I tried that already, but then Access came up with an error that there's no active control...

Any other id?

tia
Bert
 
I think that means that there is no active control on your screen i. no control has the focus.

If you place that code on a button it will display the name of the button you just clicked.

What is it exactly you are trying to achieve?
 
No, that isn't the problem.
I'm writing an add-in and there I want to know which database-object is select in the database window (i.e. the name of the query in the query-list that is currently selected).
When you've a look at the parameters of the docmd.selectobject-command, you can see that the third parameter is 'indatabasewindow'. By setting that parameter to True, you can select an object in the database window. Now i want the reverse, which object the user selected.
So is has nothing to do with a control or something like that...

Bert
 
I would suggest if you haven't already done so , that you read these articles by Helen Feddema go to the article numbers: 36/76/77/108

Extract from 108
Tips for Add-in Writers
When you run an add-in, the code is running from another database (the add-in library database), and you need to take this into account when referencing database objects in your code
 
Sorry Bert,

Totally misunderstood you - is this closer

Code:
MsgBox Application.CurrentObjectName
 
Thank you Uncle Gizmo, I know. (I can say te have some experience with writing COM Add-ins ;))
The problem itself doesn't have anything to do with an add-in or not, in Access itself the problem is the same.
 
Hi dan-cat,

You're great! That's what i was looking for :)
 

Users who are viewing this thread

Back
Top Bottom