Set Data Entry = False on form when opening

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jacc14
    New Member
    • Jun 2007
    • 116

    Set Data Entry = False on form when opening

    I have created a form and from the main menu I click a button and it opens my form so I can enter new records. The Data Entry is set to true so that i can do this.

    I would like to use the same form later in the database to recall my entries and my using the following code I double click on a field (machine) and it should bring up my form which i can view.

    Code:
    Private Sub machine_DblClick(Cancel As Integer)
    Dim gstrwhereid As String
    
        gstrwhereid = "[urn] = " & Me!urn
    'will open form where id matches line clicked
        DoCmd.OpenForm FormName:="frm_timesheet_header", wherecondition:=gstrwhereid
        DoCmd.Close acForm, Me.Name
    
    End Sub
    However I need the form to have DataEntry = False as otherwise I get an empty form. how can i do this. I entered in the code in the above
    Code:
     Me.Dataentry = false
    but this did not work.

    Any help appreciated.
    Thanks
    Christine.
  • missinglinq
    Recognized Expert Specialist
    • Nov 2006
    • 3533

    #2
    Are you aware that setting Data Entry to Yes is not necessary in order to enter new records?

    Data Entry = No
    AllowAdditions = Yes
    AllowEdits = Yes

    will allow the adding of new records and the viewing/editing of existing records.

    Linq ;0)>

    Comment

    • jacc14
      New Member
      • Jun 2007
      • 116

      #3
      hi. I have done this but when I wish to open the form to add a new record I wish it to open as a blank form. It currently brings up the data from the first record in the table.
      Thank You
      Christine

      Comment

      • TheSmileyCoder
        Recognized Expert Moderator Top Contributor
        • Dec 2009
        • 2322

        #4
        In the code you posted, you do not specify which datamode the form should open in. It will then default to the forms set properties. To override the forms property you can specify a datamode as shown below
        Code:
        DoCmd.OpenForm FormName:="frm_timesheet_header", wherecondition:=gstrwhereid ,[U][B]datamode:=acFormedit[/B][/U]

        P.S. Using Me.DateEntry will affect only the form in which it is coded, you cannot use Me. to modify another form. If you want to modify the properties of another form, you could use:
        Code:
        DoCmd.OpenForm FormName:="frm_timesheet_header", wherecondition:=gstrwhereid
        Forms("frm_timesheet_header").form.DataEntry=False
        In this case its important that the order of the two lines is maintained, as the 2nd line of code only works on a open form.
        Note however, that this, will only work if the form being opened is not opened in modal mode (I.e. form keeps focus, thus essentially pausing the code until the form is closed agian. If it is modal, the 2nd line of code would only run, after you have closed frm_timesheet_h eader".

        Comment

        • jacc14
          New Member
          • Jun 2007
          • 116

          #5
          Thank you very much. works first time.

          Best regards Christine.

          Comment

          Working...