I am having a textbox that saves its value in a field on a table.
I am wondering if there is a way that i can detect the entry of two words so
i can save them into two separate fields based on the first and second word
CurrentDb.Execute "UPDATE Values SET [ID] = '" & (first word from Me.Input)
& "' WHERE [Key] = " & Me.Record
CurrentDb.Execute "UPDATE Values SET [Name] = '" & (second word from
Me.Input) & "' WHERE [Key] = " & Me.Record
is it possible??
Brendan Reynolds - 03 Nov 2006 11:40 GMT
Use the InStr function to look for a space within the text, and the Left$
and Mid$ functions to parse it. Here are some examples using the Immediate
Window for illustration purposes ...
? InStr(1, "Some Text", " ")
5
? Left$("Some Text", InStr(1, "Some Text", " ") -1)
Some
? Mid$("Some Text", InStr(1, "Some Text", " ") + 1)
Text
See the help topics for the above functions for more information.

Signature
Brendan Reynolds
Access MVP
>I am having a textbox that saves its value in a field on a table.
> I am wondering if there is a way that i can detect the entry of two words
[quoted text clipped - 9 lines]
>
> is it possible??
Klatuu - 03 Nov 2006 15:15 GMT
Dim varSplit As Variant
Dim strSQL As String
varSplit = Split(Me.Input, " ")
strSQL = "UPDATE Values SET [ID] = '" & varSplit(0) & "'"
If UBound(varSplit) > 0 Then
strSQL = strSQL & " , [Name] = '" & varSplit(1) & "'"
End If
strSQL = strSQL & WHERE [Key] = " & Me.Record & ";"
CurrentDb.Execute strSQL, dbFailOnError
> I am having a textbox that saves its value in a field on a table.
> I am wondering if there is a way that i can detect the entry of two words so
[quoted text clipped - 6 lines]
>
> is it possible??
John Vinson - 03 Nov 2006 17:39 GMT
>I am having a textbox that saves its value in a field on a table.
>I am wondering if there is a way that i can detect the entry of two words so
>i can save them into two separate fields based on the first and second word
If you're really doing this with people's names, don't forget that
some single names consist of two or more words. I have known people
with first names "Bobbie Lou" and "Rhoda Mae" - and that is the name
they use in day to day conversation; and last names like "van der
Steen" or "de la Cruz" are not uncommon.
John W. Vinson[MVP]