Results 1 to 2 of 2
  1. #1
    Tvanduzee is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jul 2012
    Posts
    39

    Change rowsource on cbo

    Hello

    Ok, here is the structure of my form/subform:
    Combo box that displays work order numbers from my tbl_WO. Populates the rest of the main form and the details associated with it on the sub-form. -- Works as it should.

    Because I do not want orphan data, and because I do have fields that are required, I cannot generate new WorkOrders in the Work Orders Table.
    What I have done is this:

    I created a form where the user can generate new Work Orders and print them off (for the guys in the shop). When they are generated, they are generated into a "tempWo" table. - So far no problem.

    Those work orders are then printed off and the shop guys can fill them out.
    When the office gets the work orders back from the shop, they enter the data.

    The work orders form has a couple different things it does. They can view the WOs one by one or they can search to find a work order. Again, so far no problem. The problem is that when the user goes to enter a new Work Order, I need to change the source to display only the Work Orders from the tempWO table. This way, they cannot select a work order that does not exist yet. I have programmed a button on my form to add a new record. I now need to put some vba in the OnClick event for the button, to change the row source of the combo box, and have the value selected become the Work Order value in the WorkOrders table (as well as all other data inputted). I then need to remove the value from the TempWOs table once the record is committed, but I can figure that out...
    Here is the code I have tried, but does not work the way I need it to. I can't figure out how to get the value into the Work Orders Combo box.



    Code:
    Private Sub Command71_Click()
    DoCmd.GoToRecord acActiveDataObject, , acNewRec
    Me.Combo63.RowSourceType = "Table/Query"
    Me.Combo63.RowSource = "TempWO"
    End Sub
    Any suggestions?

    Thank You
    Terry

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    You have to requery the combobox after changing the RowSource:
    Me.Combo63.Requery

    Removing record from TempWO table would be DELETE sql action. Assuming WO is text:
    CurrentDb.Execute "DELETE FROM tablename WHERE WO='" & Me.Combo63 & "'"

    Why would a WO be 'orphan'? Personally, I would find a different method than temp table for input. I use 'temp' tables only for extreme situations where they facilitate data manipulation for output, in which case I would purge all records when the output process is completed.
    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. RowSource question
    By ermcc in forum Access
    Replies: 3
    Last Post: 07-11-2012, 08:16 AM
  2. .RowSource Combo
    By white_flag in forum Access
    Replies: 1
    Last Post: 09-06-2011, 07:59 AM
  3. RowSource Value not writing to the Table
    By tbassngal in forum Queries
    Replies: 5
    Last Post: 09-03-2011, 12:16 PM
  4. combobox rowsource
    By dirkvw in forum Forms
    Replies: 3
    Last Post: 06-20-2011, 05:12 PM
  5. SQL Rowsource
    By DSTR3 in forum Queries
    Replies: 2
    Last Post: 12-06-2010, 11:06 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