Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Add command button to form in datasheet view

Posted on 2014-01-09
3
Medium Priority
?
7,378 Views
Last Modified: 2014-01-09
Is it not possible to add a command button to a form in the detail section when the form is open in datasheet view?  If this can be done I must be doing something wrong because it is not showing up.
0
Comment
Question by:SteveL13
3 Comments
 
LVL 12

Assisted Solution

by:pdebaets
pdebaets earned 668 total points
ID: 39768067
No, you cannot add a button to a form in datasheet view. Either convert the form to a continuous form, or put the datasheet in a subform on another form. Then you can add the button to the continuous form or to the parent form containing the subform.
0
 
LVL 49

Assisted Solution

by:Dale Fye
Dale Fye earned 664 total points
ID: 39768076
Nope, no command buttons in datasheet view.

What I generally do is put the datasheet form into another form as a subform.  then put a command button in the main form that will perform some operation on the record selected in the subform.
0
 
LVL 40

Accepted Solution

by:
PatHartman earned 668 total points
ID: 39768164
I also embed all datasheet forms in a main form to give me a header/footer area where I can put buttons and selection combos.  This also solves the problem when you are using a switchboard where you can't directly open a form in DS view since the command is different.  But it causes a different problem in that the where argument of the OpenForm method no longer filters the form's data so you need to use the OpenArgs and add a little code to your Load event.

If you want a button on each line, you have to actually use a different control type such as a textbox.  You can format it to make it stand out and put your code in its click event.  Since most people are used to clicking on hyperlinks to go somewhere on web apps, I usually format my "button" to look like a hyperlink so the user understands that if he clicks on it something will happen.  Of course if you need the field to do double duty, you can't use the click event.  You would then need to use the double-click event for the follow hyperlink action.

Here's another little trick.  If you are still using sizable forms (I am since I don't care much for the tabbed interface), you can make your ds subform resize along with your main form with the following code.
Private Sub Form_Resize()
    Const LeftRightPadding = (0.125 + 0.25) * 1440
    Const TopBottomPadding = (0.25 + 0.375) * 1440
    
    Me.sfrmClient.Height = Me.InsideHeight - TopBottomPadding
    Me.sfrmClient.Width = Me.InsideWidth - LeftRightPadding
End Sub

Open in new window

As you can see it goes into the MAIN form's Resize event.  You will need to play with the numbers to get it to work for your particular form.  You also, obviously, need to change the name of the subform control to match your own.
1

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Suggested Courses

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question