Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / November 2006

Tip: Looking for answers? Try searching our database.

Two words in a text box

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David - 03 Nov 2006 10:51 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

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]
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.