Results 1 to 4 of 4
  1. #1
    vgreen is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    2

    Copy a query result to a form

    Hi All:


    I am very new to access and have created a database that is supposed to be used for customer service reps to call various customers. There are certain fields on the form that are pre-populated from a report that I ran using a separate application. However on the form I have inserted a button which opens up another form which allows you to search for varioius individuals based on a zip code. The results appear in a subform embedded in this search form. I would like to somehow select one of the query results to populate the previous form. Is there a way for me to do that by either copying the record or using some other function? I am an Access novice and have no programming experience (i.e. SQL), so if there is a way for me to do this by navigating the Access GUI that would be great! thanks in advance for your help.
    -vgreen

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,619
    Use VBA code to execute an SQL INSERT action. Perhaps in a button Click event. Example showing text, date, number datatypes:

    CurrentDb.Execute "INSERT INTO tablename(fieldname1, fieldname2, fieldname3, etc) VALUES('" & Me!fieldname1 & "', #" & Me!fieldname2 & "#, " & Me!fieldname3 & etc & ")"

    Then refresh the first form to display new record.
    Forms!formname.Requery
    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
    vgreen is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    2
    I do not mean to sound slow, but I am completely confused by the response. As I state earlier I am not a coder, is there a way that you can explain this to me in laymens terms or step-by-step? Thanks for responding to me with your feedback.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,619
    1. Create a button on the second form.
    2. On the Properties Sheet for the button, Event tab, Click event, select [Event Procedure]
    3. Click the ellipses (...) to open the VBA editor in the procedure
    4. Type code. Use your actual field and form names
    CurrentDb.Execute "INSERT INTO tablename(fieldname1, fieldname2, fieldname3, etc) VALUES('" & Me!fieldname1 & "', #" & Me!fieldname2 & "#, " & Me!fieldname3 & etc & ")"
    Forms!formname.Requery
    Me.Close
    5. Test and debug (refer to link at bottom of my post)

    Google: Access introduction to programming

    Review
    http://office.microsoft.com/en-us/ac...010341717.aspx
    http://www.access-vba.net/
    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: 12
    Last Post: 06-25-2012, 01:42 PM
  2. Replies: 1
    Last Post: 06-09-2012, 05:44 PM
  3. inserting query result in a form
    By nichmeg in forum Forms
    Replies: 1
    Last Post: 10-17-2011, 06:42 AM
  4. Use query result to open form.
    By Playerpawn in forum Access
    Replies: 3
    Last Post: 05-12-2011, 11:18 PM
  5. HELP! Display a query result into form
    By leanne in forum Forms
    Replies: 15
    Last Post: 06-23-2010, 09:18 PM

Tags for this Thread

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