Avatar of Earl Wolf
Earl Wolf
 asked on

Can I open a table to edit using a button in Access 2013?

I would like to open a table to edit (when necessary) using a button. The button will reside on a form that I created for a Main Menu. The name of the table is "ListofDetectives -tbl". I tried this ( docmd.opentable "ListofDetectives -tbl", acviewnormal).

Is this the correct syntax? If so, where would I place it? I do understand that buttons are really for forms, records, reports. I am curious if this can be done.
Thanks
Earl
Microsoft AccessMicrosoft Applications

Avatar of undefined
Last Comment
PatHartman

8/22/2022 - Mon
Ferruccio Accalai

you must apply the VBA code in YourButton_Click event procedure as the following:

Private Sub YourButton_Click()
      DoCmd.OpenTable "ListofDetectives -tbl", acViewNormal, acViewNormal, acEdit
End Sub
Earl Wolf

ASKER
Thanks for the syntax. Should this be placed in the event on click setting in the buttons properties?
Jim Dettman (EE MVE)

Earl,

 Just as a side comment and a cautionary note: this is normally not something you'd do.   Tables should not be worked with directly, but via forms.

 When a table is opened directly, there is no control you can apply over what happens.  

 With Forms and controls, you have properties and methods you can use to ensure data integrity, format, etc.

Jim.
Your help has saved me hundreds of hours of internet surfing.
fblack61
Ferruccio Accalai

Anyway
@ Should this be placed in the event on click setting in the buttons properties?
Yes
Earl Wolf

ASKER
Thanks Ferruccio, I appreciate it.

Jim,
I totally agree with you. My client would like to see this done. I've tried talking him out of it, but he's persistent about it. I asked why, his reply was, this is how it was done in their old DB. I told him he could get any data he wants via queries.

This is the reason I am asking.
Earl
Back
Submit

FEATURED POST
ASKER CERTIFIED SOLUTION
PatHartman

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Earl Wolf

ASKER
Pat,
Thanks for your feedback. Excellent idea to create the form in DataSheet view. I will insist this is the better approach.
Earl
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
PatHartman

The poster selected this comment as his best option.