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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Splitting a text field

Status
Not open for further replies.

rcorbett

Instructor
Nov 25, 2002
24
US
I have a drop-down box where users can select a name - this name contains both first and last which is derived from a query. After the selection I want this name to be split into two fields, First and Last and placed in their appropriate table. Thanks for your assistance.

More info - I did a query to concatenate the field names First and Last, because I wanted both names to appear in the drop down list. That works fine - now I need them to split again so they will go into the first and last field names in the table.
 
Hi
I think you don't need to split
You can put into your dropdown the 3 fields [FIRST NAME] - [LAST NAME] - [FIRST & LAST NAME] and only let the field [FIRST & LAST NAME] visible.
Then, you've just have to handle the values of the 2 others colums and put them into your fields

Hope that helps

SEB
 
Not sure I follow you on how to handle the first and last name. Thanks for the input.
 
You should parameter your DropDown like that

DropDown.RowSourceType = "Table/Query"
DropDown.RowSource = "SELECT [LastName], [FirstName], [LastName] & [FirstName] as [First and Last Name] FROM myTable"
DropDown.ColumnCount = 3
DropDown.ColumnWidths = "0;0;2835" 'the two first columns have widths =0 to be hidden, only the one containing the concatenated fields is visible

And then, You sould use that code into your form

Private Sub DropDown_Click()
txtLastName = DropDown.Column(0)
txtFirstName = DropDown.Column(1)

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top