Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2002

    Unanswered: Test for Datasheet view in VB Code

    I need to be able to test whether the user is viewing the form in datasheet view or in the regular form view. If in the form view I want to disable some fields, where in the datasheet view I only want to lock them. Is there an easy way to do this, or should I just make 2 forms?

  2. #2
    Join Date
    Oct 2002
    Leicester - UK
    add this code to the form being opened

    Sub Screen(test)
    If test = acFormDS Then <fieldname>.Locked = True Else: <fieldname>.Visible = False
    End Sub


    Private Sub <Open_As_DataSheet_Button>_Click()
    DoCmd.OpenForm "<form_name>", acFormDS
    me.Screen (acFormDS)
    End Sub

    Private Sub <Open_As_Normal_Form_Button>_Click()
    DoCmd.OpenForm "<form_name>", acNormal
    me.Screen (acNormal)
    End Sub

    to the calling buttons remember to set the <> bracket names to the ones you need

    just make sure that the item at the top of the tab order isn't the item your hiding because you cant hide the active control
    Last edited by m.timoney; 12-04-02 at 12:26.
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts