I have a table that has city, state zip in one field so the data reads like this
or a more literal example isCode:City, State Zip
How can I split the State (GA) out of that field and into it's own column in the query?Code:Atlanta, GA 00000
I have a table that has city, state zip in one field so the data reads like this
or a more literal example isCode:City, State Zip
How can I split the State (GA) out of that field and into it's own column in the query?Code:Atlanta, GA 00000
Use the Split() function
https://docs.microsoft.com/en-us/off...split-function
Please use # icon on toolbar when posting code snippets.
Cross Posting: https://www.excelguru.ca/content.php?184
Debugging Access: https://www.youtube.com/results?sear...bug+access+vba
oops, seems no available in a query
You could use Instr() twice?, once to find first space (or the comma) and once to find the next space. along with a mid() ?
Alternative create your own Split?
Code:Public Function MySplit(strToSplit As String, iIndex As Integer) MySplit = Split(strToSplit)(iIndex) End FunctionCode:? mysplit("Atlanta, GA 00000",1) GA HTH
Please use # icon on toolbar when posting code snippets.
Cross Posting: https://www.excelguru.ca/content.php?184
Debugging Access: https://www.youtube.com/results?sear...bug+access+vba
City: Left(fieldname, InStr(fieldname, ",") - 1)
State: Mid(fieldname, InStr(fieldname, ",") + 2, 2)
Zip: Mid(fieldname, InStrRev(fieldname, " ") + 1)
Last edited by June7; 06-08-2021 at 02:15 PM.
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
...and call it from a query (if need be).Alternative create your own Split?
Or Instr +2 to find 1st character of state, then Mid(of that point,2)?
The more we hear silence, the more we begin to think about our value in this universe.
Paraphrase of Professor Brian Cox.