How add command button to a form in datasheet view

I have a form which has a query as its control source.  The form opens as a datasheet view.  Somehow I want to add a command button to the form (in datasheet view) that opens a second form when clicked.  Can this be done?
SteveL13Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Connect With a Mentor Commented:
Sorry:

    DoCmd.OpenForm "YourFormName"
    Forms("YourFormName").txtJobN = Me.txtJobN


mx
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
Well, since the Header and Footer are not exposed in Datasheet view, the only place you can add a button is in the Detail section. So, each row would have the button.

mx
0
 
SteveL13Author Commented:
Actually, I tried that.  I added a command button in the detail section of the form and it doesn't display in the datasheet view.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
SteveL13Author Commented:
And I also do want it to display on all the records if I could get it to show up.
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
OOPS ... that's right ... the button will not show in DS view. Your only option is to put the DS form on a main form ... and your button there.

mx
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
I suppose you could ... add a blank text box ... and use the Double Click event to open the other form.  

mx
0
 
Rey Obrero (Capricorn1)Commented:


would you consider using a continuous form for this?
0
 
SteveL13Author Commented:
So, here is another approach I'd like to use.  I need to stick with the datasheet view.  But with a double-click event on the 1st form I want the second form to open.  I have that working fine.  But both forms have a text box named "txtJobN".  When the second form opens after double clicking on the "gray box" to the far left of the record in the first form, I need txtJobN to autopopulate on the 2nd form with the txtJob from the first form.  How can I do this?
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
Of course, a button *will* work on a continuous form.

mx
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
Use this code in the button:

DoCmd.OpenForm "YourFormName", , , "[JobN]=" & Me.txtJobN

mx
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
If JobN is Text and not Numeric then:


DoCmd.OpenForm "YourFormName", , , "[JobN]=" & Chr(34) & Me.txtJobN & Chr(34)

mx

0
 
SteveL13Author Commented:
I tried both...
DoCmd.OpenForm "YourFormName", , , "[JobN]=" & Me.txtJobN
and
DoCmd.OpenForm "YourFormName", , , "[JobN]=" & Chr(34) & Me.txtJobN & Chr(34)
and neither worked.  JobN is a numeric field.
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
Of course, replace the 'YourFormName' with the actual name of your form

mx
0
 
SteveL13Author Commented:
Worked!  Thank you.
0
All Courses

From novice to tech pro — start learning today.