Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Add command button to form in datasheet view

Posted on 2014-01-09
3
Medium Priority
?
6,890 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 48

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 39

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

715 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