copying data from query into a form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kelly McCracken
    New Member
    • Oct 2010
    • 1

    copying data from query into a form

    I am trying to get information from a query and paste it into my form. I have a table called Plans that has insurance plans that we currently offer. When we have a new group that we are quoting, I want to be able to choose a dropdown box, pick a plan and have it update the table attached to my form. Is this possible? I've looked all over the internet for code, and nothing seems to be working for me. Here is the code I have so far, not even sure this will work, but it will give you an idea on what I'm trying to do:

    Code:
    Public Sub DuplicatePlan()
    
    Set qdefPold = CurrentDb.CreateQueryDef("SELECT * FROM RiderEntry WHERE FACTSPlanName=Forms!Group!Rates.Form.PickPlan")
    Set rstPold = qdefPold.OpenRecordset
    
    Set qdefPnew = CurrentDb.CreateQueryDef("SELECT Rates * FROM Rates WHERE grID=Forms!Group!gID")
    Set rstAnew = qdefAnew.OpenRecordset
    
    With rstPnew
    
        .AddNew
        
        !RM1Rider = rstPold!M3Rider
        !rARider = rstPold!ARider
        !rBRider = rstPold!BRider
        !rCRider = rstPold!CRider
        !rDRider = rstPold!Drider
        !rERider = rstPold!ERider
        !rDPRider = rstPold!DPRider
        !rEPRider = rstPold!EPRider
        !rGRider = rstPold!GRider
        !rHRider = rstPold!H1Rider
        !rJRider = rstPold!JRider
        !rKRider = rstPold!KRider
        !rLRider = rstPold!LRider
        !rNRider = rstPold!NRider
        !rPRider = rstPold!PRider
        !rQRider = rstPold!QRider
        !rFRider = rstPold!FRider
        !rFRiderDed = rstPold!F15Rider
            
        .Update
        .MoveLast
        .Close
    End With
    rstPold.Close
    Set qdefPold = Nothing
    Set rstPold = Nothing
    
    Set qdefPnew = Nothing
    Set rstPnew = Nothing
    
    
    End Sub
    Needless to say, it doesn't work! :)

    Thank you,

    Kelly
  • malcolmk
    New Member
    • Sep 2010
    • 79

    #2
    do you mean that when you pick a plan name from a drop down box you want the plan details to appear on the form? Or you want the customer details appended to a table listing customer and what plan they are on ?

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32661

      #3
      Kelly, you need to have a rethink of how these things work in Access. It's actually a lot simpler than you're making it.

      A ComboBox control has a Row Source property, where you define the data that populates the control, and a Control Source property, to specify which field in the form's bound table the data is stored to when the record is saved.

      Comment

      Working...