Cmd button to open table?

C

CW

I want a simple cmd button on one of my forms that will open a table in
datasheet view - could somebody help with the code for this please?
Many thanks
CW
 
G

gvaughn

Yeah, in the click_event write
Docmd.OpenForm FormName, acFormDS
the acFormDS should open your form in datasheet view.
 
G

gvaughn

the code is:
Docmd.OpenForm YourFormsName, acFormDS

acFormdDs opens forms in datasheet view.
 
C

CW

Thanks but as I said in my original post it is a table that I want to open,
not a form...
 
D

Dirk Goldgar

CW said:
I want a simple cmd button on one of my forms that will open a table in
datasheet view - could somebody help with the code for this please?


A statement like this will do it:

DoCmd.OpenTable "YourTableName"

However, you should be aware that from a developer's perspective, letting
your users work directly in the tables is a dangerous thing, as you give up
all control over what they do, and you can't provide good user-interface
behavior.
 
C

CW

Thanks Dirk and I note and fully accept your caution. I'm only going to give
access (no pun intended) to one user whom I know to be very responsible and
careful, otherwise I realise I could be exposing us to all manner of problems.
And if anything does go wrong I will know it was only she or me, so fairly
easy to track down.
Many thanks
CW
 
C

CW

I get an error - I need to add an argument apparently... how should this be
expressed?
Many thanks
CW
 
D

Dirk Goldgar

CW said:
I get an error - I need to add an argument apparently... how should this be
expressed?


That statement doesn't require any other arguments, though it has some
optional arguments that you don't need to specify. It shouild work as
posted, once you've changed "YourTableName" to the name of your table. The
table name does have to be enclosed in quotes, as shown.

Please post your code and the exact error message you're getting, and
indicate which code statement is flagged as raising the error.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top