carrp
asked on
Get selected table name
How can I get the name of a highlighted table in Access? I want a function that returns the name of the selected table.
ASKER
My intention was to right-click on a table icon in the database window and run a function on it. I already have that function written, but it needs the name of the table as an input. It's certain that the table will have focus when the function is run. If someone could provide me with code that simply pops up a message box with the table name, I can take it from there.
'START!
For Each tdf In SourceDb.TableDefs
.MoveFirst
Do Until .EOF ' Write the tdf.name to the list box, combo, whatever
.MoveNext
Loop
next
'END!
use this for a combo box on a pop up form. then, have your function run when a command button (also on this form) is clicked. the function can pull the table name from the combo box.
getting the idea?
nex
For Each tdf In SourceDb.TableDefs
.MoveFirst
Do Until .EOF ' Write the tdf.name to the list box, combo, whatever
.MoveNext
Loop
next
'END!
use this for a combo box on a pop up form. then, have your function run when a command button (also on this form) is clicked. the function can pull the table name from the combo box.
getting the idea?
nex
ASKER
Nexus,
That's not a bad way to approach the problem, but it's not exactly what I'd like to accomplish.
I really want the function to return ONLY the name of the selected/highlighted table. This is because the name will be passed to another function, which manipulates data.
I want to be able to right-click the table (thus putting it in focus), and choose the function from the pop-up menu. I've already written code for the manipulation function, but I can't figure out a way to return only the name of the selected table. Any ideas?
That's not a bad way to approach the problem, but it's not exactly what I'd like to accomplish.
I really want the function to return ONLY the name of the selected/highlighted table. This is because the name will be passed to another function, which manipulates data.
I want to be able to right-click the table (thus putting it in focus), and choose the function from the pop-up menu. I've already written code for the manipulation function, but I can't figure out a way to return only the name of the selected table. Any ideas?
A request has been made to refund and/or delete this question; if there are no objections within 72 hours, the request will be granted.
EXPERTS: Please leave your thoughts on the disposition of this question here.
Banath
EE Moderator
EXPERTS: Please leave your thoughts on the disposition of this question here.
Banath
EE Moderator
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
For Each tdf In SourceDb.TableDefs
.MoveFirst
Do Until .EOF ' Write the tdf.name to the list box, combo, whatever
.MoveNext
Loop
next