Results 1 to 3 of 3

Opening a form at a blank record

  1. #1
    Remster is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Sep 2010
    Posts
    186

    Opening a form at a blank record

    Folks

    This is probably the easiest questions someone will have to answer. I want a form to open at a blank record rather than the first record. I've found this suggestion on another site:

    In the forms' on open event put (A2000 but I think it's the same in 2003):

    DoCmd.GoToRecord , , acNewRec

    This will ensure that when the form is opened it always opens to a new
    record, not an existing one.
    I realise that the code is Visual Basic, and I'm used to working with Macros in Excel, but I'm new to Access and can't for the life of me work out where I'm supposed to put this sort of code. Can anyone help? Easy steps would be good.

    Thanks

    Remster

  2. #2
    Remster is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Sep 2010
    Posts
    186
    Well, I've worked this one out, but after I've added the code I get an error message when opening the form:

    Member already exists in an object module from which this object module derives.

    Here are the other pieces of code that I have in the form:

    Private Sub FindFormByReference_AfterUpdate()
    ' Find the record that matches the control.
    Dim rs As Object

    Set rs = Me.Recordset.Clone
    rs.FindFirst "[ID] = " & Str(Nz(Me![FindFormByReference], 0))
    If Not rs.EOF Then Me.Bookmark = rs.Bookmark
    End Sub


    Private Sub FindFormByName_AfterUpdate()
    ' Find the record that matches the control.
    Dim rs As Object

    Set rs = Me.Recordset.Clone
    rs.FindFirst "[ID] = " & Str(Nz(Me![FindFormByName], 0))
    If Not rs.EOF Then Me.Bookmark = rs.Bookmark
    End Sub


    Private Sub Form_Current()
    ' Synchronize name in combo box with displayed record.
    FindFormByReference = ID
    FindFormByName = ID
    End Sub


    Private Sub New_person_Click()
    On Error GoTo Err_New_person_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

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

    Exit_New_person_Click:
    Exit Sub

    Err_New_person_Click:
    MsgBox Err.Description
    Resume Exit_New_person_Click

    End Sub


    Does anyone understand why I'm having this problem?

  3. #3
    Remster is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Sep 2010
    Posts
    186
    I've finally worked it out! False alarm.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 08-27-2010, 04:16 AM
  2. Combo box shows blank on opening the Form
    By Alex Motilal in forum Forms
    Replies: 7
    Last Post: 01-15-2010, 09:59 AM
  3. Opening form to correct record. Bookmark?
    By stephenaa5 in forum Forms
    Replies: 11
    Last Post: 12-29-2009, 12:43 PM
  4. blank on entry on add a record form
    By gmee in forum Forms
    Replies: 1
    Last Post: 10-07-2009, 06:31 AM
  5. Replies: 1
    Last Post: 03-15-2009, 03:46 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Tech Forums: Microsoft Office Forums