Hi all,
I am trying to comew up with a way to use regex coupled with a Select Case to validate some data. Here's what I have.
On my form I have an unbound text box that is used to query a single table called address and output to a listbox. If a user inputs a house number e.g. "1111" the list of addresses is for any address begin with that number. Conversely, if the user inputs a road name e.g. "ADAMS AVE" the query will output to the listbox all addresses with "ADAMS AVE" in it. This is currently accoomplished with a regex.test for the text box like so, assume regex declarations have been made:
[
regex.pattern = "\d"
result = the regex code....yes I know this is NOT actual code
If result then
do a query to return address by house number
Else
do a query to return addresses by road name
End If
set rowsoure for listbox
requery listbox
]
What I want to add is the capability to have *1111 ADAMS* and know (using regex) as a validation that this is a search for an address WHICH may be incomplete.
To accomplish this I thought of using a Select Case but am not sure how to pass the single textbox value through a Select Case.
I imagine it somewhat like this:
[declare regex stuff)
Select Case return
Case "\d"
Run Query by House Number
Case "\w+"
Run Query by Address Road Name
Case "d{1,5} \w+"
Run query by House Number and Address Road Name where left (for so many characters is the house number) and remaining right is Address Road Name.
End Select
Any thoughts are VERY welcome!
Daneil
I am trying to comew up with a way to use regex coupled with a Select Case to validate some data. Here's what I have.
On my form I have an unbound text box that is used to query a single table called address and output to a listbox. If a user inputs a house number e.g. "1111" the list of addresses is for any address begin with that number. Conversely, if the user inputs a road name e.g. "ADAMS AVE" the query will output to the listbox all addresses with "ADAMS AVE" in it. This is currently accoomplished with a regex.test for the text box like so, assume regex declarations have been made:
[
regex.pattern = "\d"
result = the regex code....yes I know this is NOT actual code
If result then
do a query to return address by house number
Else
do a query to return addresses by road name
End If
set rowsoure for listbox
requery listbox
]
What I want to add is the capability to have *1111 ADAMS* and know (using regex) as a validation that this is a search for an address WHICH may be incomplete.
To accomplish this I thought of using a Select Case but am not sure how to pass the single textbox value through a Select Case.
I imagine it somewhat like this:
[declare regex stuff)
Select Case return
Case "\d"
Run Query by House Number
Case "\w+"
Run Query by Address Road Name
Case "d{1,5} \w+"
Run query by House Number and Address Road Name where left (for so many characters is the house number) and remaining right is Address Road Name.
End Select
Any thoughts are VERY welcome!
Daneil