Results 1 to 9 of 9
  1. #1
    snipe's Avatar
    snipe is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    287

    Best way to pull a "StoreCode" into a field, and insert that into a table

    Hey,



    I have a form for payroll for the 16 assistant managers in my company. This form inputs 16 different fields into a table, and then calculations are done from that data.

    HR will click a combo box to pick which manager they want to enter data for. There is a store code as well (01 through 08). I want that store code to auto-populate after a salesperson is selected. That value also needs to get inserted into the table.

    What is the best way to go about this?

    I am perfectly fine with macros or VBA

    Also: the employee data gets pulled from ODBC

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    In the AfterUpdate event of the Combobox you could use Dlookup or another method to get the store code

  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,632
    If you need to permanently save the store code in the record because personnel can move around, that will require code.

    As ItsMe suggested, use the AfterUpdate event of combobox to set value of field.

    Include store code as a column in the combobox RowSource and refer to that column by index. Index begins with 0. Column 1 is index 0, etc.

    Me!StoreCode = Me.combobox.Column(x)
    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
    snipe's Avatar
    snipe is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    287
    I am using a text box as the control for the store. (should I?) Whats the vba command to change the value of it to the dlookup value?

  5. #5
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Where is the value, "store"? Can you include it in the combobox's recordset?

  6. #6
    snipe's Avatar
    snipe is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    287
    Ok June7, I did that. Technically, it works.

    But the field only updates when the user clicks into the store code field (which I plan to have locked and disabled). I have the code in the After Update event on the combo box.

    Ideas?

  7. #7
    snipe's Avatar
    snipe is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    287
    Quote Originally Posted by ItsMe View Post
    Where is the value, "store"? Can you include it in the combobox's recordset?
    Yes, and it actually was already in the combo box due to the box being sorted by store, then last name. I didn't even think to just grab the value from there. But I am still having a small issue. See my previous response.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    The code works fine for me.

    If you select combobox item by mouse click the code should trigger right away.

    If you type into the combobox the code won't trigger until leave the combobox by tab, enter, or mouse.
    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.

  9. #9
    snipe's Avatar
    snipe is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    287
    Quote Originally Posted by June7 View Post
    The code works fine for me.

    If you select combobox item by mouse click the code should trigger right away.

    If you type into the combobox the code won't trigger until leave the combobox by tab, enter, or mouse.
    I was clicking. I deleted the store code field and remade it. Works like expected now. Not sure what residual code/crap I had on that text box after all of my attempts.

    I appreciate the help guys!

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

Similar Threads

  1. Replies: 3
    Last Post: 04-22-2013, 06:08 AM
  2. Replies: 2
    Last Post: 12-04-2012, 01:03 AM
  3. table field name "Year" causing Argument Not Optional
    By JosmithTwo in forum Programming
    Replies: 2
    Last Post: 09-26-2012, 08:01 PM
  4. Replies: 16
    Last Post: 07-22-2011, 09:23 AM
  5. Field "F1" does not exist in table (Tablename)
    By HelenP in forum Import/Export Data
    Replies: 3
    Last Post: 11-26-2010, 09:13 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