Results 1 to 4 of 4
  1. #1
    overlords is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2013
    Posts
    12

    add to cart button


    I have a seemingly simple problem that I can't for the life of me figure out. I have a continuous form that is populated by a simple query. On each 'record' in this continuous form, there is a 'cart' button, for when someone wishes to buy the item in question. This button should take the itemID from that record and append it to the 'purchases' table. This is probably super easy, but I've been at this all day and perhaps I just need a fresh pair of eyes to point me in the right direction. Thanks to anyone who can help.

    I've attached a picture of the form to help understand what I'm trying to do. Please excuse the colors, I'm color blind.
    Attached Thumbnails Attached Thumbnails product browser.png  

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,646
    Why doesn't it work, what happens - error message, wrong results, nothing?

    Need to see code behind the Cart button.
    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
    overlords is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2013
    Posts
    12
    There's no code behind the button. It's just there as a visual aid. I played with the idea of using an append query but I don't think that's the right path to take, since what I'm really trying to do is single out the item ID of that particular record. I think VBA would be the best option here, which is my problem, I don't know where to start. Or perhaps there's a more obvious solution that I haven't thought of.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,646
    In the Click event of button select [Event Procedure]. Click the ellipses (...) to open VBA editor at the procedure. Type code, like:

    CurrentDb.Execute "INSERT INTO Purchases(itemID) VALUES(" & Me.itemID & ")"

    I suspect also need customer ID in there but I don't know your db well enough to be more specific. Include whatever fields you want in the SQL. Syntax example for text, date, number:

    CurrentDb.Execute "INSERT INTO tablename(field1, field2, field3) VALUES('" & Me.textbox1 & "', #" & Me.textbox2 & "#, " & Me.textbox3 & ")"
    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: 8
    Last Post: 04-03-2013, 05:32 PM
  2. Replies: 0
    Last Post: 01-11-2012, 12:34 PM
  3. Replies: 10
    Last Post: 03-21-2011, 02:46 PM
  4. Replies: 1
    Last Post: 07-27-2010, 02:27 PM
  5. Replies: 6
    Last Post: 02-09-2010, 07:53 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