Results 1 to 5 of 5
  1. #1
    tyewonk is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2013
    Posts
    8

    What am I missing???

    What am I doing wrong?


    If I change the combo box to read 126, it says it will append 0 rows.
    However, if I remove the variable portion and replace it with 126, it wants to append 1 row. (i.e. WHERE tblItems.UPC = '126'; )

    Code:
    Private Sub cboUpcScan_AfterUpdate()
    Dim strSQLUPCScan As String
    strSQLUPCScan = "INSERT INTO tblItemsSold (UPCSold, DescSold, PriceSold) SELECT UPC, DESC , List FROM tblItems WHERE tblItems.UPC = '" & Me.cboUpcScan & "';" 
    DoCmd.RunSQL (strSQLUPCScan)
    End Sub

  2. #2
    tyewonk is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2013
    Posts
    8
    Came across another site that said lookup fields are evil and cause this issue. I switched combo box to a text box and works now. I just loose the dropdown feature...

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Lookups with alias are evil if set up in table, otherwise they have valid use on forms. Just have to get the referencing correct. Refer to the item ID, not the UPC code. Of course, if you are using the UPC as a primary key, would be different situation.

    Why are you even trying to save the item UPC, description, cost values? Just save the item ID. Why do you need to use INSERT sql action instead of doing data entry directly into the destination table through a bound form?
    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.

  4. #4
    tyewonk is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2013
    Posts
    8
    Well, for one, because I am new to access and most of what you just said is jibberish to me. LOL. With my limited knowledge I need these to make it work the way I know how for the time being. As I progress I will rewrite this or start over, but for now i just need something that works, even if its ugly.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    You are taking what would normally be the harder approach and one that seems odd for a newbie to even be aware of.

    Bind form to table, that means set the form RecordSource property. Bind controls (textbox for one) to fields of the form recordset, that means set the control ControlSource property. Anything entered into the control by whatever method passes directly into record of table. This is basic Access functionality.

    If you have already set up bound form and controls, use of the INSERT sql action makes no sense.

    If you really don't want to use bound form, then need to know more about your data and the combobox. Sounds like you are using an autonumber as the primary key for items and not the UPC. Also sounds like it is not a multi-column combobox and does not include the ID in a column. Review http://www.datapigtechnologies.com/f...combobox3.html
    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. What am I missing????
    By Loc in forum Queries
    Replies: 6
    Last Post: 05-25-2013, 07:11 PM
  2. Missing entries
    By Baldeagle in forum Queries
    Replies: 3
    Last Post: 11-07-2012, 10:47 AM
  3. What is missing in it?
    By cap.zadi in forum Forms
    Replies: 7
    Last Post: 10-05-2011, 12:47 AM
  4. ok what am i missing here ?
    By baseborn in forum Forms
    Replies: 6
    Last Post: 12-21-2010, 01:46 PM
  5. Probably missing something easy
    By z1efuller1 in forum Database Design
    Replies: 5
    Last Post: 11-12-2009, 11:18 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