Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Jun 2002
    Posts
    114
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Go to new record in another form (Access 2000)

    I want to open another form, go to new record and copy the text of CompanyName into the new form:
    Forms![FCustomers]![CompanyName] = Me![CompanyName]

    My problem is that i get the following error : The command
    acCmdRecordsGoToNew isnt available now
    My code is the following


    Dim stDocName As String
    Dim stLinkCriteria As String
    stDocName = "FCustomers"
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    Dim rst As DAO.Recordset
    Set rst = Forms![FCustomers].RecordsetClone
    ' first find the blank fields with CompanyName in order to make use of them
    rst.FindFirst "CompanyName Is Null"
    If rst.NoMatch = True Then
    RunCommand acCmdRecordsGoToNew
    Else
    Forms![FCustomers].Bookmark = rst.Bookmark
    End If
    Forms![FCustomers].CompanyName.SetFocus
    Set rst = Nothing
    DoCmd.GoToControl "CompanyName"
    Forms![FCustomers]![CompanyName] = Me![CompanyName]

    On my second form a have a control for a new record, and there my code works.It is not
    always working when i open the form from another form and want to go to a new
    record.
    Why is it so ? The problem is that sometimes, in rare occasions it works, and all that puzzles
    me.

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Go to new record in another form (Access 2000)

    This seems to me to be a pretty convoluted method for doing what you want to do. If you have the CompanyName already displayed on the first form, the most straightforward method is to open the second form in the data entry mode, which automatically starts a new record as soon as you copy the CompanyName to the text box on the second form.
    Wendell

  3. #3
    2 Star Lounger
    Join Date
    Jun 2002
    Posts
    114
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Go to new record in another form (Access 2000)

    Thank you fro your reply. This will
    be the solution.How can i describe the Data entry mode
    in the DoCmd.OpenForm line ?

    regards

  4. #4
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Go to new record in another form (Access 2000)

    Use :
    DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormAdd
    Francois

  5. #5
    2 Star Lounger
    Join Date
    Jun 2002
    Posts
    114
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thank you

    Thank you to you all !! That is exactlly what i needed!

Posting Permissions

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