Results 1 to 3 of 3
  1. #1
    rivereridanus is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2011
    Posts
    71

    autofill field in form based on field in previous form

    I'm not very experienced with vba coding, so I need help with this.


    I have two forms, [New Person] and [questionnaire], both with the field personid. Personid in New Person is an autonumber.

    I have a button called "continuebutton" which should have code to save the record in New Person, close New Person, and open questionnaire with questionnaire.personid = New Person.personid.

    Here is what I have. Could anyone help?

    Private Sub continuebutton_Click()
    docmd.OpenForm(questionnaire,,,,,) (I know there's something wrong here)
    Form.Dirty = False
    DoCmd.Close
    End Sub

  2. #2
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    First, move the code around to this:

    Code:
    Private Sub continuebutton_Click()
    Me.Dirty = False
       DoCmd.OpenForm "questionnaire", DataMode:=acFormAdd
       Forms!questionnaire.personid = Me.personid
    DoCmd.Close acForm, Me.Name, acSaveNo
    End Sub

  3. #3
    rivereridanus is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2011
    Posts
    71
    Thanks. That did it!

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

Similar Threads

  1. PLEASE help: Autofill based on one field
    By Suzanne in forum Forms
    Replies: 5
    Last Post: 07-07-2011, 11:09 AM
  2. Make new field based on previous field's answer
    By VictoriaAlbert in forum Access
    Replies: 1
    Last Post: 04-11-2011, 09:54 PM
  3. Autofill from Previous Field
    By Dan Kenton in forum Forms
    Replies: 1
    Last Post: 02-16-2011, 11:15 PM
  4. Autofill form fields based on another field
    By ljs1277 in forum Access
    Replies: 3
    Last Post: 02-16-2010, 02:51 PM
  5. Autofill field based on autonumber field
    By frevilla in forum Forms
    Replies: 1
    Last Post: 09-11-2009, 02:50 AM

Posting Permissions

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