Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 14th, 2005, 02:42 PM
Registered User
 
Join Date: Dec 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to CORiverRat Send a message via MSN to CORiverRat Send a message via Yahoo to CORiverRat
Default String Type Statement to convert field

I need to know how to take a text field and be able to take only the characters out of it up to the first '.' in it. Example: Host Name field includes BobsPC.MyVLAN.MYNetwork. I need to be able to strip just Bob's PC and create an entry in my database that has just that information in it. Figure I need either to do it with an expression or criteria but can't find a specific example of how to do it. Any help would be greatly appreciated.

Thanks.

Roger

 
Old December 14th, 2005, 02:58 PM
Friend of Wrox
 
Join Date: Dec 2005
Posts: 142
Thanks: 0
Thanked 0 Times in 0 Posts
Default

srchstr = Forms![frmName]![fldName]
trimstr = Trim(srchstr)
brk_pos = InStr(1, trimstr, ".")
If brk_pos <> 0 Then
    end_str = Left(trimstr, brk_pos - 1)
Else
    end_str = trimstr
End If


Variable names are of course arbitrary, those are just what were used in the DB I was working on. Had to parse a City, State search entry into separate values to be part of a table search.
 
Old December 14th, 2005, 05:44 PM
Registered User
 
Join Date: Dec 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to CORiverRat Send a message via MSN to CORiverRat Send a message via Yahoo to CORiverRat
Default

This doesn't look like what I was looking for. I basically wanted to keep the info in the same record and just read the original field, parse off the info I don't need and write it into a different field in the same record.



 
Old December 14th, 2005, 05:49 PM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

It looks like Kindler's code will work. What you will want to do is put this inside of a public function, inside of a module, and then run a SQL statement like...

UPDATE tblMyTable SET newField = functionName(oldField)

Yell is you need more info to implement this...

Mike

Mike
EchoVue.com
 
Old December 14th, 2005, 06:24 PM
Friend of Wrox
 
Join Date: Dec 2005
Posts: 142
Thanks: 0
Thanked 0 Times in 0 Posts
Default

What Echo said, I wasn't sure what you meant by "create an entry" and whether you meant an entry in another table, or filling in a field in the current table, so I left that part of the coding up to you.

 
Old December 15th, 2005, 02:13 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

Another handy string function when working with consistent delimiters in addresses, paths, etc....

Public Function SplitString(srchstr As String) As String
    Dim x As Variant
    x = Split(srchstr, ".")
    SplitString = x(LBound(x))
End Function






Similar Threads
Thread Thread Starter Forum Replies Last Post
code of convert xml data type in string by C# prafullaborade XML 2 May 24th, 2008 07:49 AM
cannot implecitly convert type bool to string vaidyapragati General .NET 1 May 4th, 2007 09:10 PM
Convert "String" type to "Control" type ? kishore_peddi C# 4 January 11th, 2006 01:21 PM
Finding Field Type & string length From dataset? Jackie VB.NET 2002/2003 Basics 4 July 9th, 2003 04:53 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.