Results 1 to 6 of 6
  1. #1
    JackieEVSC is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Oct 2011
    Posts
    70

    Create new record, open form populated with that info

    I have a from with a combo box that populates other records in the form based on the choice. I need to code a button on that form that creates a record in an existing table and opens that record on different form, which they would then add addtional information. I'm sure it's not as difficult, but I've tried everything and it's not working. Can anyone direct me to a resource to help me with this? Thanks.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,618
    The table is not part of the form's RecordSource? Use INSERT sql action to insert record to that table. In VBA could use CurrentDb.Execute "INSERT INTO table name (fieldnames) VALUES(values)"

    Then code to open form and move to the last record or filtered to a specific record.

    Or simply open form to new record. Then set values of fields with code.
    DoCmd.OpenForm "FormB", , , , acFormAdd
    Me!fieldname = somevalue
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    JackieEVSC is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Oct 2011
    Posts
    70
    Thanks ... I'm closer!! The new form opens, but I wasn't able to code it properly to get the form populated. I need it to open where the field TicketNum (in the repair table, which this button populated) that corresponds with an unbound text field (Text60) in the form I'm leaving.

    Here is my code ...

    DoCmd.OpenForm "frm_RepairTicket", , , , acFormAdd
    Me!TicketNum = Text60

    I changed it to ...
    DoCmd.OpenForm "frm_RepairTicket", , , , acFormAdd
    Me!Text60 = TicketNum

    But it still didn't work. I'm not a programmer, and I'm sure it's something silly I'm doing. Everything I do is by trial and error, and it's an arduous journey!

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,618
    I should have clarified how to use the code for setting field values.

    In the second form Open event:
    Me!TicketNum = Forms!form1name.Text60

    The 'Me' qualifier can only be used to reference the form/report the code is behind.

    Is it possible you could use a form/subform arrangement with these two forms?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    JackieEVSC is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Oct 2011
    Posts
    70
    I'm familiar with sub-forms and use them frequently, I'm just not sure how that will work with this. Let me briefly explain what I'm attemting to do and see the sub-form is what I need.

    The StudentInfo form opens with a combo dropdown with a list of student names, studentID, their school, and the asset and serial tag number(s) of any netbook/laptop assigned to them (a student can have more than one assigned if their original is in for repairs, etc.). The information for this combo pulls from a query against a SQL based library database and an AS400 mainframe database.

    That information, as well as a new repair ticket number (Text60) is on this form.

    We have 24 schools that assign netbooks/laptops to students. I chose to incorporate the repair ticket number because the student with that same unit could be in the repair table already, and I wanted it to go specifically to the record created with that repair ticket number. The ticket number and the auto-number primary key in the new record are the only unique identifiers in the new record.

    Am I making this more complicated that it needs to be?

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,618
    Need to know more about data structure. I presume linked tables are read only? Save the computer ID to ticket table. What table is the second form bound to, where is the TicketNum being saved by that form?

    Do you want to provide project for analysis? Make copy, remove confidential date, create surrogate tables for the linked tables, run Compact&Repair, zip if still large, attach to post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 3
    Last Post: 04-27-2011, 06:34 PM
  2. new record open form
    By tubar in forum Forms
    Replies: 5
    Last Post: 03-31-2011, 12:33 PM
  3. If record does not exist, open add new record form
    By RobertIngles in forum Programming
    Replies: 2
    Last Post: 02-01-2011, 08:47 AM
  4. Pulling Record Info From Sub Form
    By redlich23 in forum Forms
    Replies: 1
    Last Post: 09-02-2009, 02:10 PM
  5. Create PDF for each record in table/form
    By ChrisCMU in forum Forms
    Replies: 15
    Last Post: 07-28-2009, 01:52 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
  •  
Other Forums: Microsoft Office Forums