Results 1 to 9 of 9
  1. #1
    Lateralusx777 is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2021
    Posts
    21

    Update query for filtered form

    I am attempting to create an update query that allows me to input a value into a specific field for all records based on a filter that the user inputs. When the form launches, it asks for the starting tag number and then the last tag number. It then pulls up all records between x and y inclusive. I have a button on the form that runs my update query. The issue I am running into is getting my update query to only update the values inside of the filter. I cannot find anything online that is helpful. Any help would be greatly appreciated.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    no, you cant update from a filter, but you CAN update based on controls on the form.
    (if that's how you filtered to begin with)

    use the form controls for the where clause in the update.

  3. #3
    Lateralusx777 is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2021
    Posts
    21
    The filter uses two values from a primary key in the table and pulls up all values in between. This will change every time the form is ran. Is there a way to specify the range without a specific control value?

  4. #4
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Posting the sql of what you tried might provide more clues and more focused answers. Seems like it ought to be as simple as " Where myfileld Between value1 And value2..."
    Not clear if the user is providing the PK values or something else or even how they're providing the values. I'm guessing Inputbox function.
    Last edited by Micron; 03-30-2022 at 11:51 AM. Reason: added comment
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    Lateralusx777 is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2021
    Posts
    21
    The user provides the values.

    The form that is opened -

    SELECT ([Field 3]*[Field 1]/12) AS Feet, [Tags]![Unit Cost]*[Tags]![Quantity] AS [Value], Tags.[Date Found], Tags.[REC Date], Int(([Field 1]*[Field 3]/12)*(([Field 4]-[Field 2])*[Field 2]*10.68)) AS TubeWeight, Tags.[Tag Number], Tags.[Prior Tag Number], Tags.Status, Tags.[PO Number], Tags.[Item #], Tags.[Cert #], Tags.Weight, Tags.[Field 1], Tags.[Field 2], Tags.[Field 3], Tags.[Field 4], Tags.[Field 5], Tags.[Field 6], Tags.[Type of Material], Tags.Comments, Tags.[Printed Tags Comments], Tags.Printed, Tags.[Invoice #], Tags.[Invoice Date], Tags.[AP #], Tags.[AP Date], Tags.[Type of Inventory], Tags.Location, Tags.Date, Tags.[Work Order #], Tags.[WO# Tags Made], Tags.SlitWorkOrder, Tags.WhseLoc, Tags.CheckBy, Tags.PackID, Tags.[B/L#], Tags.CoilType, Tags.Quantity, Tags.[Unit Cost], Tags.UOM, Tags.Temper, Tags.[Item Master #], Tags.[BP Code], Tags.[Spare Flag], Tags.[Spare Flag 2]
    FROM Tags
    WHERE (((Tags.[Tag Number]) Between [Enter First Tag #] And [Enter Last Tag #]));

    The update query -


    UPDATE Tags SET Tags.[Work Order #] = [Forms]![View Tags Filtered]![Work Order #]
    WHERE (((Tags.[Tag Number])=[Forms]![View Tags Filtered]![Tag Number]));

  6. #6
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Tags.[Tag Number] is part of the form recordsource by the look of it so I'd either have 2 unbound textboxes (invisible) that receive the 2 values. When you run the append, reference both of those controls as WHERE Tags.[Tag Number] BETWEEN [Forms]![View Tags Filtered]![BeginTag] AND [Forms]![View Tags Filtered]![EndTag]. However, better to use Inputbox rather than simple parameter prompts - can't retrieve values from parameter prompts AFAIK.

    In other words, I agree with Ranman - refer to form controls, not the control value as you mentioned. You might have one control that shows the tag field value for a record, but you need 2; 1 for beginning and 1 for ending value, so 2 hidden controls.
    Last edited by Micron; 03-30-2022 at 12:18 PM. Reason: added info
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    Lateralusx777 is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2021
    Posts
    21
    Thank you. I will try this and let you know!

  8. #8
    Lateralusx777 is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2021
    Posts
    21
    I have not had any luck with this. I am fairly new to access and have not used input boxes before. Is there a way to set the value of two invisible text boxes to the first and last value in a specific field?

  9. #9
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Should be doable - as long as you use a query, not a table, and can sort the records correctly and reliably. Access has First and Last functions, but they can produce unexpected results so I'd try to stay away from them. You'd need to sort the query and use Min and Max on some field that gives you access to the values you need.

    Or post what you last tried and explain the outcome.
    Or post a zipped db copy with instructions. As per post 2, if your query is filtered, there shouldn't be an issue updating only that subset of records. I don't think you've adequately explained what the problem is regarding the updating.

    BTW, work order and tag number fields are number data type (not text)?
    And since there are so many fields in the Select query, I'm wondering how many are not included. Might be easier to just write SELECT * ?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Update Records in Filtered Form
    By PSSMargaret in forum Programming
    Replies: 18
    Last Post: 01-19-2021, 06:08 AM
  2. Replies: 28
    Last Post: 01-29-2018, 06:40 PM
  3. Replies: 13
    Last Post: 04-16-2014, 10:11 AM
  4. Filtered Report from filtered datasheet form
    By gemadan96 in forum Reports
    Replies: 7
    Last Post: 01-03-2014, 05:12 PM
  5. update query fon a filtered form HELP!
    By campanellisj in forum Queries
    Replies: 0
    Last Post: 11-12-2010, 09:08 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