disable datasheet view in form

  • Thread starter Thread starter John Milbury-Steen
  • Start date Start date
J

John Milbury-Steen

Hi Access gurus:

I am using Access 2002.
I have a popup form which I want to open only in datasheet view. In the
properties list of the form, I have the following settings:

Default View: datasheet
Allow Form View: No
Allow Datasheet View: Yes

However, the form still opens in Form View! What do I have to do to enforce
Datasheet View?
 
John Milbury-Steen said:
Hi Access gurus:

I am using Access 2002.
I have a popup form which I want to open only in datasheet view. In
the properties list of the form, I have the following settings:

Default View: datasheet
Allow Form View: No
Allow Datasheet View: Yes

However, the form still opens in Form View! What do I have to do to
enforce Datasheet View?

I'm guessing this only happens when you open the form with code, using
DoCmd.OpenForm. Right? When you use DoCmd.OpenForm to open a form, as
opposed to doing it via the Access user interface, you must specify that
you want to open the form in anything other than form view; e.g.,

DoCmd.OpenForm "MyPopupForm", acFormDS
 
I'm guessing this only happens when you open the form with code, using
DoCmd.OpenForm. Right?

I didn't write any code to open the form. I open the form via a button.
 
John Milbury-Steen said:
I didn't write any code to open the form. I open the form via a
button.

The button is using either VBA code or a macro to open the form. Was
the button created by the Command Button Wizard? If so, it will have
code for its Click event that looks something like this:

Private Sub Command0_Click()
On Error GoTo Err_Command0_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Form1"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command0_Click:
Exit Sub

Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click

End Sub

(where "Command0" is the name of the button, and "Form1" is the name of
the form being opened). What you would need to do is edit this code and
change this line:

DoCmd.OpenForm stDocName, , , stLinkCriteria

to this:

DoCmd.OpenForm stDocName, acFormDS, , stLinkCriteria

That should do it. Do you know how to get at the button's code to edit
it?
 
Back
Top