I have a table->column first-name with values:
Juan
Manuel l.
Richard Wit
I'm trying to do a query that return
开发者_运维技巧Juan
Manul
Richard
I want to eliminate after a space.
Assuming you want SQL, try
SELECT MID(name + " a", 1, INSTR(name + " a", " ")-1) AS FirstName FROM myTable
In VBA it would be similar, since Mid() and InStr() work exactly the same as in Access-SQL
Really, though, it would be better to just store first and last name in separate fields so you don't have to do this sort of finagling in the SQL.
SELECT Left([First-Name], InStr([First-Name] & ' ', ' ') - 1) As CleanFirstName
FROM table
Keep in mind that running this will be inefficient since you will be executing VBA functions against every record in your query. Depending on how you are using this, you may want to have the query return the full field and do the processing after the fact.
精彩评论