Datasheet Command Button (1 Viewer)

Richie2837

Registered User.
Local time
Today, 19:01
Joined
Jan 30, 2007
Messages
88
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.
 

boblarson

Smeghead
Local time
Today, 11:01
Joined
Jan 12, 2001
Messages
32,059
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
 

Richie2837

Registered User.
Local time
Today, 19:01
Joined
Jan 30, 2007
Messages
88
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?
 

missinglinq

AWF VIP
Local time
Today, 14:01
Joined
Jun 20, 2003
Messages
6,423
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
 

Users who are viewing this thread

Top Bottom