Results 1 to 11 of 11
  1. #1
    Courtney91 is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Jan 2017
    Posts
    4

    Form based on a query


    Hi. I've created a form based on a query for tractors.. for example I have the field 'make' and I've set it up to search for jcbs, when I want to change it to search for John Deeres for example the query works but the form does not update... can someone please explain to me how to do this.

  2. #2
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,471
    Try this in AfterUpdate event of the combobox(assume name of combobox and field in table is called "make":

    Me.Filter = "make = '" & me.make & "'"
    Me.FilterOn = True

  3. #3
    NTC is offline VIP
    Windows 7 64bit Access 2013
    Join Date
    Nov 2009
    Posts
    2,392
    A form must have its record set requeried. One can close & reopen the form - or at an appropriate event you must trigger the code: me.requery

  4. #4
    Courtney91 is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Jan 2017
    Posts
    4
    Thank you for your responses!
    I have head of requery and tried it (propabkt doing it wrong)
    Could someone explain to me how to do this?

    I'd also like to set up a button that allows me type in for example jcb or tractor and it brings up the relevant data instead of always doing it design view of a query first. How could this be done?

    Btw my form does update when I close it and reopen. But that's annoying to do all the time

  5. #5
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Do post #2. The third line is Me.Requery

  6. #6
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,471
    You can do the me.filter option or do a requery of the data after you select a value from a combo box for example. If you can close and reopen your form and it shows the correct data, sounds like you already have the correct criteria in your form's query? So in properties for that "make" field, in the Events tab in AfterUpdate, add Forms!YourFormName.Requery so it will rerun the query for your form.

  7. #7
    Courtney91 is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Jan 2017
    Posts
    4
    I still can't get it to work
    The form updates but I have to close the form and rerun it instead of just refreshing which is what I want to do.

    If i start from scratch in the property sheet box in form.. what exactly do I need to put in so when I open my form it asks what I want to search for?
    Is it also possible for it to ask me the make of what I want to search and also the model (these two fields are already set up)

    Trying to make his sound as much sense as I can :')

  8. #8
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    How is the user selecting the make, is it a combobox? The filter/requery will be done in the AfterUpdate of the combobox, once the user has selected the make.

  9. #9
    Courtney91 is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Jan 2017
    Posts
    4
    At the minute I'm doing a search in the query table saving then opening the form... I tried a combo box but it only lets you select the full make and model, I want to search for specific make

  10. #10
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Well, I suggest that you get the combobox working before moving on with this. In Access, that is the accepted way of selecting which data to show to the user. You can set it to display any thing you want (not sure what you mean by specific make). If you are doing wildcard searches, such as looking for all records that being with a R, then make a textbox and in the VBA you will change the SQL to reflect that. You will then have criteria in your query referencing the combobox (=Forms!FormName!ComboboxName) and then the filtering.

  11. #11
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Maybe you would post your dB?

    (Do a "Compact & Repair", then Zip it.)

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

Similar Threads

  1. Replies: 3
    Last Post: 07-26-2016, 02:12 PM
  2. Replies: 3
    Last Post: 06-18-2014, 10:40 AM
  3. Replies: 7
    Last Post: 07-11-2013, 10:45 AM
  4. Replies: 18
    Last Post: 10-10-2012, 10:10 AM
  5. Replies: 1
    Last Post: 07-25-2011, 09:10 AM

Tags for this Thread

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