Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pulling out the first occurence of a four-digit number from a field

Status
Not open for further replies.
I doubt instr() will work unless you know what the values will be. I expect a user created function will be required that loops through every character in the field until it finds four consecutive numeric digits.

Rydel,
Try write the pseudo code of what you would do manually. Come back with the pseudo code if you need help with actual VBA code.

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
dhookom: I can do it in VBA too (and if I don't get an answer here, that's what I'll do I guess). I just wanted to do it directly just by running _one_ SQL statement without having to write ~30 lines of VBA code.

regards,
rydel n23
 
dhookom, while you are correct that it would not work in most cases, I was assuming that there is some consistency in this respect. However, if there is not consistencey, your are totally correct.
 
Perhaps something like this ?
BirthYear: Mid([field name], InStr([field name], "19"), 4)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top