Solved

Add command button to form in datasheet view

Posted on 2014-01-09
3
4,829 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
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 47

Assisted Solution

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

Accepted Solution

by:
PatHartman earned 167 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.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

896 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

13 Experts available now in Live!

Get 1:1 Help Now