Query
6 TopicsAccess Query Expressions not working: Replace, InStr
I am trying to run a relatively simple query and receive a compile error. The two fields involved are both text fields. SELECT Spouse, Replace(Spouse, Last, "") AS Result FROM SimplifiedTable; What this query should do is look at a text Spouse field, and, if the last name is present in it, replace it with blanks. Ideally, I would add an RTrim to the thing to just get the first name of the spouse.I have tried the same query with brackets around the fields, with tableName.fieldname, etcetera. No joy: Compile error. in query expression 'Replace(Spouse, Last, ""'. (It also errors if I try using single quotes -- is there an escape I should be using?) Additionally, I enlisted the assistance of AI and tried to do the same thing using InStr -- Here's a sample of other approaches attempted: SELECT Spouse, IIf(Spouse Like "*" & [Last] & "*", Left(Spouse, InStr(Spouse, [Last]) - 1), Spouse) AS Result FROMSimplifiedTable; SELECT Spouse, IIf(Spouse Like "*" & [Last] & "*", Left(Spouse, Len(Spouse) - Len([Last]) + 1), Spouse) AS Result FROM SimplifiedTable; Each of these queries received the same error message (the quoted text the only differentiator). If I run a select query on just the fields, or concatenate them, no problem. Thanks!769Views0likes4CommentsAccess 365 Query
I am using Access 365 on Windows 10 PC. My database is in Access 2016 format. I haven't used Access in some time and am perplexed by my difficulty in successfully designing a query. I have a list of members of a legislature. One of the fields is office type; the choices are Legislative Office, Constituency Office or Ministry Office. I have tried multiple options in my Simple Query to obtain a list of Legislative offices. No matter what I've tried, I get blank results with a syntax error message. Among my attempts where "Legislative", "Legislative Office" and "not C" None have been successful. Screenshots attached show table format, query design view and syntax error. Please point me in the right direction. Thanks in advanceSolved1.1KViews0likes4CommentsLinking an external query to a field in a form
I have a form where the record source is a query joining several tables. There is a field for location (NationalGridReference). I have an external query (NGR_to_XY) which converts NationalGridReference to two numeric fields (X and Y). I want to have an X and a Y field in the form that automatically populate from NGR_to_XY. Whenever I join NGR_to_XY to the form's query it no longer allows editing of any fields in the form, although the X and Y fields are populated correctly. How can I join the NGR_to_XY query and still be able to enter data into the form? I did find this questionbut the solution uses VBA which I don't know how to use, is there a way that just uses regular design view?Solved1.1KViews0likes3CommentsSet up query to find missing data in multiple fields
Hey Microsoft Community, I am trying to set up a query that will find records that are missing data. For example, I have a main form where users will enter biographical data, but they may be missing the birthday, the last name, and the phone number. The idea is that this query will help us identify the records which are missing data and allow us to then go back and enter this data in when we find it. How would I set up the query to catch the records with any missing data? I first tried to place "Is Null" (not in quotes) in the OR section of the query, and it worked with only one field being tested, but as I added more fields it could not find a record with missing data. As always thank you for taking the time to read this and help with this issue. I look forward to your response. Thanks, EbSolved5.7KViews0likes4CommentsSubset in a larger set
Hello I have a large table with positions (personnel). Some positions may be occupied by more than one person during the year; consequently, position numbers repeat if I also get the name of the person and the date. Position Name LastName EndDate 1234 John Sullivan 31/12/2020 8546 Susan Kent 03/15/2020 8546 Juan Valdez 09/30/2020 3454 Samir Bhutteer 31/10/2020 How can I run a qry to get only the second record for 8546, that is the most recent occupancy? I guess I need to nest the SELECT statements, but I don't know how. Thank you LeonelSolved1.1KViews0likes3CommentsQuery Design
I am trying to make a total row in my query design that can be used to AVG or COUNT my data. However, my program does not have that row readily available to me. If anyone has any tips or solutions I would love to hear them. This is for a homework assignment that is due tomorrow.982Views0likes1Comment