Go Back   Access World Forums > Microsoft Access Discussion > Forms

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 01-30-2007, 12:23 PM   #1
Richie2837
Newly Registered User
 
Join Date: Jan 2007
Location: Wales, UK.
Posts: 88
Thanks: 0
Thanked 0 Times in 0 Posts
Richie2837 is on a distinguished road
Send a message via MSN to Richie2837
Datasheet Command Button

I want to be able to place a command button on my form, which when clicked will open up the same data that is displayed on my form but in datasheet view. (i.e. all the records, not just the current record)

Is there a piece of code which will do this?

If there is, would there also be a way to apply a filter or parameter query to this command, so it only opens up records which match a particular field - i.e. records of all people who have been selected as "yes" in the Computer User field.

Thanks.

Richie2837 is offline   Reply With Quote
Old 01-30-2007, 12:26 PM   #2
boblarson
Smeghead
 
boblarson's Avatar
 
Join Date: Jan 2001
Location: Oregon, USA
Posts: 32,068
Thanks: 97
Thanked 1,828 Times in 1,579 Posts
boblarson is a splendid one to behold boblarson is a splendid one to behold boblarson is a splendid one to behold boblarson is a splendid one to behold boblarson is a splendid one to behold boblarson is a splendid one to behold boblarson is a splendid one to behold
You can create a separate form and open it on the click of the button and specify to open in Datasheet mode.

Code:
DoCmd.OpenForm "FormNameHere", acFormDS
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
boblarson is offline   Reply With Quote
Old 02-02-2007, 03:05 AM   #3
Richie2837
Newly Registered User
 
Join Date: Jan 2007
Location: Wales, UK.
Posts: 88
Thanks: 0
Thanked 0 Times in 0 Posts
Richie2837 is on a distinguished road
Send a message via MSN to Richie2837
Thanks Bob,

The code behind this button is now:

Private Sub TalkingBooksUsers_Click()
On Error GoTo Err_TalkingBooksUsers_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Talking Books Users"
DoCmd.OpenForm "Talking Books Users", acFormDS
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_TalkingBooksUsers_Click:
Exit Sub

Err_TalkingBooksUsers_Click:
MsgBox Err.Description
Resume Exit_TalkingBooksUsers_Click

End Sub

I have created a new form and set it to open in datasheet view, but when the command button is clicked it opens in form view. However, opening the form directly opens it as datasheet, so what am I doing wrong?

Richie2837 is offline   Reply With Quote
Old 02-02-2007, 03:44 AM   #4
missinglinq
AWF VIP
 
missinglinq's Avatar
 
Join Date: Jun 2003
Location: Richmond (Virginia that is!)
Posts: 6,311
Thanks: 11
Thanked 718 Times in 668 Posts
missinglinq is a glorious beacon of light missinglinq is a glorious beacon of light missinglinq is a glorious beacon of light missinglinq is a glorious beacon of light missinglinq is a glorious beacon of light missinglinq is a glorious beacon of light
You're opening the form twice, the second time not in datasheet view!
Try replacing

Code:
DoCmd.OpenForm "Talking Books Users", acFormDS
DoCmd.OpenForm stDocName, , , stLinkCriteria
with

Code:
DoCmd.OpenForm stDocName, acFormDS, , stLinkCriteria
__________________
The Devil's in the Details!
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


(All code solutions tested in Access 2003/2007, before posting, unless otherwise noted.)
missinglinq is offline   Reply With Quote
Old 02-02-2007, 04:26 AM   #5
Richie2837
Newly Registered User
 
Join Date: Jan 2007
Location: Wales, UK.
Posts: 88
Thanks: 0
Thanked 0 Times in 0 Posts
Richie2837 is on a distinguished road
Send a message via MSN to Richie2837
That works! Brilliant!

Thanks.

Richie2837 is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Binding a datasheet subsubform to a datasheet subform Dugantrain Forms 11 08-06-2017 10:06 AM
Shortcut to Datasheet View form omer610 Forms 2 01-04-2005 05:47 AM
Opening new form with record selected in datasheet. jonifen Forms 3 03-09-2004 04:04 AM
open to specific record in datasheet deekras Modules & VBA 1 11-10-2003 02:21 PM
Change DefaultView on subform from Datasheet to Continuous casey Forms 2 01-11-2003 10:01 AM




All times are GMT -8. The time now is 09:16 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World