Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2002

    Lightbulb Unanswered: Open a Form without showing first record

    Hi All,
    I want to open a form, which having a record source...and i want that when i open the form just show the blank "Add New record'...only display data when user select when of the combobox's value...
    Please help....

  2. #2
    Join Date
    Nov 2002
    San Francisco

    Re: Open a Form without showing first record

    you can specify filter when you open your form, so specify record, which does not exist or better specify few records ....

    Docmd.openform "frmMyForm", "SELECT * FROM myTable WHERE myID = 111111111"

    + you can create simple function which changes LOCKED=NO to LOCKED=YES and vice versa for all fields in any form... so when user opens the form, everything is locked and he can see only one record and needs to unlock it (click a button or select something from combo). I had app, where most of the users wanted to see the data and sometimes they wanted to update something... lock/unlock feature prevented tons of errors.

    this is very simple sub for lock/unlock (allowdelete, edit and append) for all fields in the form and one level subforms.... you can improve it.... I did it few years ago.

    simply after you pick something from combo run
    ChangeAccessRights "frmMyFrom", True, True, True

    Public Sub ChangeAccessRights(InputForm As String, AllowEdit As Boolean, AllowDel As Boolean, AllowAdd As Boolean)

    Dim MyControl As Control
    On Error Resume Next

    If IsLoaded(InputForm) Then
    For Each MyControl In Forms(InputForm).Controls
    If MyControl.ControlType = acSubform Then
    MyControl.Form.AllowEdits = AllowEdit
    MyControl.Form.AllowAdditions = AllowAdd
    MyControl.Form.AllowDeletions = AllowDel
    End If
    Forms(InputForm).AllowEdits = AllowEdit
    Forms(InputForm).AllowAdditions = AllowAdd
    Forms(InputForm).AllowDeletions = AllowDel
    End If
    End Sub

    Function IsLoaded(ByVal strFormName As String) As Integer
    ' Returns True if the specified form is open in Form view or Datasheet view.

    Const conObjStateClosed = 0
    Const conDesignView = 0

    If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> conObjStateClosed Then
    If Forms(strFormName).CurrentView <> conDesignView Then
    IsLoaded = True
    End If
    End If

    End Function


  3. #3
    Join Date
    Dec 2002
    Columbus, GA

    Re: Open a Form without showing first record

    On the form DESIGN view, go to Properties and choose

    DATA ENTRY and set to YES

    This will hide all previous records. To see them all, you just click the A/Z button and it will show them all.

Posting Permissions

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