Page 2 of 2 FirstFirst 12
Results 16 to 22 of 22
  1. #16
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556

    The ABCOutdoor_ProductList has to be the name of the subform control?
    Most times that will be the same as the subform name unless you change it (which I always do)

    Upload a cutdown version of your DB with enough to replicate the problem, else we could be here another week.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  2. #17
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,933
    @Kipandrews06

    I also recommend you read responses in full and make sure you understand thm - it would appear you only read the first sentence or two them skim the rest because the same advice has been provided over the last 10 responses or so

  3. #18
    Kipandrews06 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Oct 2021
    Posts
    54
    Sorry for the delay in my response. I had an incredibly busy last couple days and am catching back up. Anyways, I sincerely apologize if I cross posted or made anyone mad at me, I don't want to be one of those annoying people. I really do appreciate you all taking the time to respond to my posts and trying to help me, I do not take that for granted. @AJAX- I did not skim the responses but I admit that I just didn't understand it. I'm very new to VBA and SQL terminology, I have a grasp of the basics, but alot of it is like a foreign language to me and a little overwhelming sometimes. Kind of like being in med school and well before graduating being thrown in to perform brain surgery lol. I don't want to appear to be really dumb, so I apologize to anyone that felt like I didn't take their advice or read what they sent me. I did however overlook the signature lines with the links to debugging. I will assuredly pay close attention to those in the future. I'm going to watch those more in depth today now that I'm back from a business trip and have more time to do so. I also want to be transparent and upfront with everyone, someone reached out to me privately on here and I have a call with them later today. I will update everyone how that goes and if it is still unresolved pending that call, I will post a sample of my database as @Welshgasman suggested. Thanks again everyone!

  4. #19
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    @Kipandrews06

    If you do not understand something, then say so. No shame in doing that, especially when you are starting out.

    I know of someone who has been using Access since 2005, has over 14K posts on a forum, and can barely put two words of VBA together in the correct order.
    Asks the same questions time and time again. Incapable of Googling. They cannot be bothered to learn, easier to get someone else to do it for you all the time.

    That person also reaches out to people privately, so beware.

    At least you are prepared to learn I hope.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #20
    Kipandrews06 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Oct 2021
    Posts
    54
    haha yeah I am definitely prepared to learn. I google relentlessly when I'm stuck and can usually find what I need, but this particular problem I'm having I have been unable to find anything that works so far so I finally broke down and posted my problem. I try my best not to submit a post unless I have been stuck for days and can't figure it out. But I love learning new things, I find access and all the programming fascinating. I have a ton to learn, but I am trying my best to pick up what I can, but I occasionally hit a road block like right now and have absolutely no clue what to do to fix it lol. Its incredibly frustrating. And like I said earlier, thank god for this forum! I sincerely appreciate the people here that take the time to help people like me. But you wont ever have to worry about me posting 14k posts and expecting people to do all the work for me. I try to only post when I have to and am desperate lol.

  6. #21
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    Sorry to jump in this late, but I think the easy solution is to remove the name of the subform control from the SQL string as you mentioned the command button (cmdAdd) is actually on the same subform, so you should have something like this:
    Code:
    Dim strInsert As StringDim db As DAO.Database
    
    
    
    strInsert = "INSERT INTO TblItemCart(ID,[Product Code],[Amt In Stock])" & _
                "SELECT ID,[Product Code],[Amt In Stock]" & _
                "FROM ABCOutdoor_ProductList" & _
                "WHERE ID = " & Me.txtID
                
    Set db = CurrentDb()
    
    
    db.Execute strInsert, dbFailOnError
    Set db = Nothing
    
    
    End Sub
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  7. #22
    Kipandrews06 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Oct 2021
    Posts
    54
    So quick update, after the call I had with someone earlier, I was able to finally figure out my problem. It turns out that I had the SQL function wrong that I started with and also some of my relationships/Links between tables were not correct (newbie errors basically) and we changed it to this and it fixed it perfectly:

    Code:
    Private Sub cmdAdd_Click()
    Dim strSQL As String
     
    Dim lngID As Long
    Dim strProductCode As String
    Dim strAmtInStock As String
     
    lngID = Me.ID
    strProductCode = Me.Product_Code
    strAmtInStock = Me.Amt_In_Stock
     
    If Me.Dirty Then Me.Dirty = False
     
    strSQL = "INSERT INTO ItemCart(ID, [Product Code], [Amt In Stock]) " & vbCrLf _
                & "Values (" & lngID & ", '" & strProductCode & "', " & strAmtInStock & ");"
        Debug.Print strSQL
        CurrentDb.Execute strSQL, dbFailOnError
    MsgBox "Item Added", vbInformation
     
        On Error GoTo 0
       
     
        Exit Sub
     
    cmdAdd_Click_Error:
              MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure cmdAdd_Click, line " & Erl & "."
             
     
    End Sub
    We made some other tweaks to it, redid my form structure, but this code is what fixed the problem I had in case someone is googling and searching for a similar issue and wanted to see how this was resolved. I really appreciate everyone's help on this! I had been stuck for over a week and was starting to lose my mind lol.

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

Similar Threads

  1. Replies: 2
    Last Post: 04-05-2019, 12:42 PM
  2. Replies: 4
    Last Post: 08-10-2018, 12:00 AM
  3. Replies: 13
    Last Post: 02-05-2018, 12:58 PM
  4. Replies: 3
    Last Post: 09-08-2017, 07:18 PM
  5. Replies: 4
    Last Post: 10-08-2012, 05:33 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