Solved

Add command button to form in datasheet view

Posted on 2014-01-09
3
4,548 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 167 total points
Comment Utility
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 47

Assisted Solution

by:Dale Fye (Access MVP)
Dale Fye (Access MVP) earned 166 total points
Comment Utility
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 34

Accepted Solution

by:
PatHartman earned 167 total points
Comment Utility
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.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

762 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

Need Help in Real-Time?

Connect with top rated Experts

5 Experts available now in Live!

Get 1:1 Help Now