Results 1 to 10 of 10
  1. #1
    chimp8471 is offline Novice
    Windows 10 Office 365
    Join Date
    May 2021
    Posts
    25

    Double Click subform to add to table after user enty


    Evening

    I am trying to streamline my database, it is a stock management database that allows users to book out stock.. It works perfectly but to be honest the process sis a bit long winded..

    I am therefore looking to ease things.

    I have a form with a subform.. I want to be able to double click a record, a form would then pop up with some of the info from that record prompting the user to enter the qty they want to remove and this data then passed to a table.

    I have attached an image of what i am trying to do.. but to be honest i have no idea where to start.

    Any help or guidance would be really appreciated.

    Thanks in advance

    Andy
    Attached Thumbnails Attached Thumbnails Form.jpg  

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    This may help with the first part.

    http://www.baldyweb.com/wherecondition.htm

    One way to accomplish the second:

    Code:
      Dim strSQL  As String
      Dim db      As DAO.Database
      Dim rs      As DAO.Recordset
    
      Set db = CurrentDb()
      
      strSQL = "SELECT * FROM TableName WHERE 1=0"
      Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)
    
      rs.AddNew
      rs!PartNumber = Me.PartNumber
      rs!Qty = Me.Qty
      rs.Update
    
      rs.Close
      set rs = nothing
      set db = nothing
    your picture raises the fact that you're displaying a text part number but saving a numeric ID.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Edited to make the items needing your actual names red.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    chimp8471 is offline Novice
    Windows 10 Office 365
    Join Date
    May 2021
    Posts
    25
    Hi Sorry for the delay in replying... been in surgery having a knee replacement....

    Huge thanks for the feedback....

    I am not very good at this so if you could help me break this down a little please:

    1.DoCmd.OpenForm "SecondFormName", , , "FieldName = " & Me.ControlName

    For my second form... do i need to create a table that sits behind the 2nd form? or is that controlled from the original data?

    2. Can i set the double click for any field on the row? or does it have to be a specific field?


    I have added a stripped down version of what i have as i can confuse myself sometimes...(to be clear i have done nothing from the feedback as i wanted to be clear first on my questions above)

    doubleclick.zip

    Thanks in advance

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    The second form would be based on the table itself or a query that returned all records.

    The double click could be behind any field, it just has to refer to the key field.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    chimp8471 is offline Novice
    Windows 10 Office 365
    Join Date
    May 2021
    Posts
    25
    ok so i have the 2nd form and created a double click on the part number and it magically loaded the 3 fields (absolutely no idea how that happened) totally guessing with this lol

    Next Question....

    How do i now add a user input field to the form where they can enter the number? as this is not in my original table or form....

    this is what i have so far...

    Click image for larger version. 

Name:	Cart Item 2.jpg 
Views:	11 
Size:	78.6 KB 
ID:	45295

  7. #7
    chimp8471 is offline Novice
    Windows 10 Office 365
    Join Date
    May 2021
    Posts
    25
    So i added a text box that allows me to enter a number... added a button!

    Code:
    Private Sub AddToCart_Click() Dim strSQL  As String
      Dim db      As DAO.Database
      Dim rs      As DAO.Recordset
    
    
      Set db = CurrentDb()
      
      strSQL = "SELECT * FROM TableName WHERE 1=0"
      Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)
    
    
      rs.AddNew
      rs!PartNumber = Me.PartNumber
      rs!QTY = Me.QTY
      rs.Update
    
    
      rs.Close
      Set rs = Nothing
      Set db = Nothing
    End Sub
    and put code on click of the button but it confuses me at this bit...

    strSQL = "SELECT * FROM TableName WHERE 1=0"

    What table am i Select * from???? or is this my new form (Frm_CartAdd_Item) or the original Table that led me to the double click (tPartdescription)

    How does it know to go to My other table (tTempPartsIssued)

    rs.AddNew
    rs!PartNumber = Me.PartNumber
    rs!Qty = Me.Qty
    rs.Update


    this bit... for me to transfer the PARTID Not the (Part Number) and New entered Item textbox (RemoveQty) is this close?


    rs.AddNew
    rs!PartID = Me.PartID
    rs!RemoveQty= Me.RemoveQty
    rs.Update

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    TableName is the table you want to insert this record into, tTempPartsIssued. What you have look like it should work.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    chimp8471 is offline Novice
    Windows 10 Office 365
    Join Date
    May 2021
    Posts
    25
    ok so you are a genius!! Thanks so much for your help

    got lots of other bits i want to do with this but will raise fresh posts as they may help others.

    I do have one final question on this section.....

    When i add to the new table, i have a list box on my form to show whats been added to the cart..... however thats not refreshing...although the items are adding to the table

    I have tried putting this on the button code but it's not refreshing....

    Option Compare Database




    Private Sub AddToCart_Click()
    Dim strSQL As String
    Dim db As DAO.Database
    Dim rs As DAO.Recordset


    Set db = CurrentDb()

    strSQL = "SELECT * FROM tTempPartsIssued WHERE 1=0"
    Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)


    rs.AddNew
    rs!PartNumber = Me.PartID
    rs!QTY = Me.RemoveQty
    rs.Update


    rs.Close
    Set rs = Nothing
    Set db = Nothing
    Me.ListBoxcart.Requery

    End Sub

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    That should work, presuming the listbox is on the popup form. If it's on the original form:

    Forms!FormName.ListBoxcart.Requery
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Double click event to filter a subform
    By Rzgar in forum Forms
    Replies: 3
    Last Post: 08-31-2019, 08:16 AM
  2. Replies: 3
    Last Post: 07-22-2015, 03:45 AM
  3. Replies: 1
    Last Post: 07-14-2015, 05:59 AM
  4. Replies: 2
    Last Post: 10-29-2014, 03:25 AM
  5. On Double Click go to Subform
    By Theremin_Ohio in forum Access
    Replies: 2
    Last Post: 03-30-2011, 08:03 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