I am trying to autopopulate data in a sub form from a table.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SamanthaR
    New Member
    • Aug 2010
    • 1

    I am trying to autopopulate data in a sub form from a table.

    I would like to simply type in an item code and have the fields: UPC, item description, pack, and size populate.
    The subform is set-up, but I do not know the code for this. I am pretty new to access and haven't done much VBA. I am unsure whether to use VBA or perhaps there is a querry. The easiest solution is probably best for me. Any help you can provide would be greatly appreciated.

    Thanks!
  • jimatqsi
    Moderator Top Contributor
    • Oct 2006
    • 1288

    #2
    Are you sure you mean a subform? A subform is a form that is part of a larger form. Generally that means the data that shows on the subform is linked to the data showing on the main form.

    Do you mean instead you are trying to set up 1 form only?

    Jim

    Comment

    • rwalle
      New Member
      • Jan 2010
      • 47

      #3
      If You´d like to have this Form / subform set up for a search propouse, you could create a query where you will display all the data for the table "Products" that are Code,UPC, Item Description,Pac k and Size
      then create a form "SearchSubF orm" based on this query, set the default view as datasheet, create another Form the "Search Form" set up a textBox "SearchText " and a Button "SearchBtn" insert the "SearchSubF orm" as a subform then in the Query design gird view into "Criteria" box for the "Code" Field write "=[Forms]![SearchForm]![SearchText]",then go to the "SearchForm " and in "SearchBtn" event "OnClick"in voke the macro builder, create a macro with the action "Requery" and under argument "SearchSubForm" , so when you click the "SearchBtn" it will run the requery Comand on the "searchSubF orm" using the text in the "SearchText Box" from the "SearchForm "

      Comment

      • walid geagea
        New Member
        • May 2011
        • 8

        #4
        i just tried it and it is so efficient, do you have any idea about how to set the "LIKE" instead of the "="

        Comment

        • Narender Sagar
          New Member
          • Jul 2011
          • 189

          #5
          Yes, If your Product codes are something like : A001, A002, B001, B002, C001, C002 etc. then, you can use : Like "A*" parameter in query. You will get desired result.

          Comment

          • rwalle
            New Member
            • Jan 2010
            • 47

            #6
            You can learn how to make a more flexible form filtering in this Neopa's Articlehttp://bytes.com/topic/access/answer...subform-filter
            and also here is the code ( based on this article) I have used to filter products based on Manufacturer Part Number or part of this number
            Code:
            rivate Sub ManNumSrcBtn_Click()
             ManNum = "([PrdPartNum]like'*" _
                  & Me!ManNumSrcBox & "*')"
            Form_ProdQryForm.Filter = ManNum
            Form_ProdQryForm.FilterOn = True
            Debug.Print Form_ProdQryForm.Filter
            End Sub
            Last edited by rwalle; Sep 14 '11, 06:58 PM. Reason: missing data

            Comment

            • rwalle
              New Member
              • Jan 2010
              • 47

              #7
              The code I wrote Build a string Variable named [ManNum], it ends as ([PrdPartNum]like*(Any Text to search)*)
              where "any text to search" is text you write down inside "ManNumSrcB ox"
              then set the Form_ProdQryFor m.filter = [ManNum] and then set the Form_ProdQryFor m.FilterOn= true
              this way

              Comment

              Working...