Hi,
I have this great function that works great if I create the table from scratch in the database. The problem is that I need it to work on a table that is linked into my database. For some reason the same function will not work if I try to use it in a query with a table linked to the database. I am new to VBA. Is there a way to fix this? Thanks in advance for your help.
Here is the code:
Function getLinkValue(s) ' takes string and returns substring before last space character in stringmaxi = Len(s) ' length of input string, controls looping through charactersLastSpace = maxi ' position of last space character in stringFor i = 1 To maxi ' loops through every character to find position of last space If (Mid(s, i, 1) = " ") Then LastSpace = i NextIf LastSpace < maxi Then LastSpace = LastSpace - 1 ' if Space was found backtracks LastSpace to last character in string getLinkValue = Mid(s, 1, LastSpace) End Function
I have this great function that works great if I create the table from scratch in the database. The problem is that I need it to work on a table that is linked into my database. For some reason the same function will not work if I try to use it in a query with a table linked to the database. I am new to VBA. Is there a way to fix this? Thanks in advance for your help.
Here is the code:
Function getLinkValue(s) ' takes string and returns substring before last space character in stringmaxi = Len(s) ' length of input string, controls looping through charactersLastSpace = maxi ' position of last space character in stringFor i = 1 To maxi ' loops through every character to find position of last space If (Mid(s, i, 1) = " ") Then LastSpace = i NextIf LastSpace < maxi Then LastSpace = LastSpace - 1 ' if Space was found backtracks LastSpace to last character in string getLinkValue = Mid(s, 1, LastSpace) End Function