locked
New record - RRS feed

  • Question

  • Hi,

    I am trying to create a new record on Access but when I arrive on my blank record (i) I cannot fill the blank fields and (ii) the labels and text fields initially defined do not appear.

    I created a control "new record" whose code is:

    "Private Sub
    New_record_Click()
    On Error GoTo
    Err_New_record_Click

    DoCmd.GoToRecord acDataForm, "My
    form", acNewRec

    Exit_New_record_Click:
    Exit
    Sub

    Err_New_record_Click:
    MsgBox Err.Description
    Resume
    Exit_New_record_Click
    End Sub"

    I think that the problem might come from the record selector which remains in position "current record"
    (triangle play) instead of the position "new record that you can enter information in".

    Many thanks!

    Monday, December 16, 2013 11:02 AM

Answers

  • I am used to the code looking more like this if you are Clicking a control on the Form you are working from.

    Private Sub New_record_Click()
    On Error GoTo New_record_Click_Err
        On Error Resume Next
        DoCmd.GoToRecord , "", acNewRec
    New_record_Click_Exit:
        Exit Sub
    New_record_Click_Err:
        MsgBox Error$
        Resume New_record_Click_Exit
    End Sub
    

    If this code doesn't work then maybe you don't have any records in your database yet, sometimes this may be the cause of the Form showing blank.

    Also look for any code that sets the control properties .visible = NO

    Hth


    Chris Ward

    • Marked as answer by George Hua Monday, December 23, 2013 4:48 PM
    Monday, December 16, 2013 5:11 PM

All replies

  • I am used to the code looking more like this if you are Clicking a control on the Form you are working from.

    Private Sub New_record_Click()
    On Error GoTo New_record_Click_Err
        On Error Resume Next
        DoCmd.GoToRecord , "", acNewRec
    New_record_Click_Exit:
        Exit Sub
    New_record_Click_Err:
        MsgBox Error$
        Resume New_record_Click_Exit
    End Sub
    

    If this code doesn't work then maybe you don't have any records in your database yet, sometimes this may be the cause of the Form showing blank.

    Also look for any code that sets the control properties .visible = NO

    Hth


    Chris Ward

    • Marked as answer by George Hua Monday, December 23, 2013 4:48 PM
    Monday, December 16, 2013 5:11 PM
  • What is the record source of your form?

    Can you add records to this record source manually (i.e. not via the form)?

    Are you sure your form has the AllowAdditions property set to True?

    Do you have WRITE permissions to the folder where your database resides?

    Monday, December 16, 2013 6:12 PM