Page 1 of 2 12 LastLast
Results 1 to 15 of 24
  1. #1
    FIZGIG is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2020
    Posts
    15

    My co-workers are too lazy to copy and paste ...


    I'm trying to modify our order sheet to be able to click on an item and it automatically adds it to an order sheet. Is it possible? Thanks.
    Attached Thumbnails Attached Thumbnails ACCESS SAMPLE.png  

  2. #2
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,879
    Yes it's possible but not enough info to provide a more indepth answer. You may also want to use a double click event to prevent accidental clicks.

  3. #3
    FIZGIG is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2020
    Posts
    15
    Thanks for responding. What extra information would you need? I attached an image for the main form used.. Did you see that?

  4. #4
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 10 Access 2016
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,538
    You would want to use VBA code similar to the following which creates a new record with the old information. You can modify this concept to meet your specific needs.

    Code:
    Private Sub copyrecordbutton_Click()
    On Error GoTo Err_copyrecordbutton_Click
    Dim txtOld1 As Variant
    Dim txtOld2 As Variant
    Dim txtOld3 As Variant
    Dim txtOld4 As Variant
    txtOld1 = txtcurrent1.Value
    txtOld2 = txtcurrent2.Value
    txtOld3 = txtcurrent3.Value
    txtOld4 = txtcurrent4.Value
    RunCommand acCmdRecordsGoToNew
    txtnew1.Value = txtOld1
    txtnew2.Value = txtOld2
    txtnew3.Value = txtOld3
    txtnew4.Value = txtOld4
    Exit_copyrecordbutton_Click:
    Exit Sub
    Err_copyrecordbutton_Click:
    MsgBox Err.Description
    Resume Exit_copyrecordbutton_Click
    End Sub

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    What extra information would you need?

    To offer focused advice/suggestions it would be helpful to
    -show a graphic of your tables and relationships in order to understand the "bigger" picture
    -some comment regarding the tables from which these forms get their data
    -a simple description in plain English of the business involved (do you have Customers, Suppliers,....?)
    -a brief overview of the processes involved in your order and inventory activities
    -a statement regarding "cost" which rarely is stable with time

    Just some thoughts for consideration.
    Think of it this way - if you were going to hire someone to "do" what you have in mind, what info would they need to know/have to complete the task? I'm sure you are intimately familiar with the business, the environment you are working in, the people, the processes, any reports etc, etc, but readers are not.

    Good luck with your project.

  6. #6
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,879
    Thanks for responding. What extra information would you need? I attached an image for the main form used.. Did you see that?
    In addition to what Orange has pointed out, I would assume you aren't actually copying from form to form but are writing from table to table. It would certainly be helpful to know table names and fields and what info needs to be written.
    I would imagine it to be a simple insert into ... select ... where ... statement with a subform requery.

    edit: BTW, those look like scratch ticket names, at least in my state.

  7. #7
    FIZGIG is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2020
    Posts
    15

    More snips

    Thanks again to those that responded. I have attached more snips of a simplified version of what I'm trying to do, does this help?
    Click image for larger version. 

Name:	Capture2.PNG 
Views:	27 
Size:	78.1 KB 
ID:	40630Click image for larger version. 

Name:	Capture1.PNG 
Views:	27 
Size:	15.7 KB 
ID:	40631

  8. #8
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,879
    Assuming you are entering the quantities in your items to order form, it appears you are only writing item code and orderID to the Items_Ordered table.


    on double click event of the item code field you would have something like


    Dim StrSql As String
    StrSql = "Insert into Items_Ordered([Item Code],[Order ID] Values(" & Me.ItemCode & "," & Parent.[Order ID] & ")"
    CurrentDb.Execute StrSql, dbFailOnError


    Parent.[Items to Order].Requery 'you'll need to set correct relative path to the subform
    You should eliminate the spacing in your naming convention. then you wouldnt need to use [] around your names.

    heres a quick example
    ex_Products.zip

    edit: sorry for sloppy example but had to get to work.

  9. #9
    FIZGIG is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2020
    Posts
    15

    Example database

    Thanks! I made some changes based on your suggestions and have included the example database. I'm getting closer to what I would like it to do but it's still not happening. Thanks again.
    Attached Files Attached Files

  10. #10
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,879
    You didnt change the name of the table or subform in the code.

  11. #11
    FIZGIG is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2020
    Posts
    15
    Quote Originally Posted by moke123 View Post
    You didnt change the name of the table or subform in the code.
    Better? But what else did I miss? It's still not working ...

    Private Sub ITEM_CODE_DblClick(Cancel As Integer)
    Dim strSql As String
    strSql = "Insert into ITEMS_ORDERED(ITEM_CODE,ORDER_ID) values(" & Me.ITEM_CODE & "," & Parent.ORDER_ID & ")"
    CurrentDb.Execute strSql, dbFailOnError
    Parent.ORDER_SHEET_ITEMS.Requery
    End Sub

  12. #12
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,879
    It's still not working
    That doesn't tell me much. I corrected the table name and the subform name and it works for me.
    What exactly is not working?

  13. #13
    FIZGIG is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2020
    Posts
    15
    Quote Originally Posted by moke123 View Post
    That doesn't tell me much. I corrected the table name and the subform name and it works for me.
    What exactly is not working?
    I double click on item number and nothing happens.

  14. #14
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    After looking at your dB, I think you should stop and have another look at the tables & relationships.

    I changed some field and object names. (all uppercase is SHOUTING)
    Play around with the attached dB to see if it is close to what you want/trying to do.

    Hover over a record that has underlining in the inventory sub form to see a tool tip.



    Good luck with your project...
    Attached Files Attached Files

  15. #15
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,879
    Heres your example back. You can double click the item number or item description in the products subform and it transfers to the ordered form. I also added a default quantity of 1 since it appeared you wanted that as a default. I also added a recalc in the after update of the quantity.

    What else is it you want it to do?

    BTW, you should consider using a primary key in all your tables.

    EXAMPLE_V2.zip

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Is it possible to copy and paste?
    By DubCap01 in forum Forms
    Replies: 1
    Last Post: 12-21-2016, 03:01 AM
  2. Macro to copy and paste
    By chr1stoper1 in forum Macros
    Replies: 2
    Last Post: 04-11-2016, 06:51 AM
  3. Copy and Paste Row (vb)
    By Computer202 in forum Programming
    Replies: 7
    Last Post: 03-28-2014, 01:59 AM
  4. Any way to copy paste records from
    By super12 in forum Access
    Replies: 5
    Last Post: 03-05-2013, 11:16 PM
  5. Copy-Paste
    By BorisGomel in forum Access
    Replies: 4
    Last Post: 10-25-2011, 07:17 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