Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 3rd, 2008, 09:16 AM
Authorized User
 
Join Date: May 2007
Location: , , .
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
Default Parsing query

Hi All,

Got a relatively easy one for all the experienced guys in the house. I've looked 15 pages deep in google searcheson several variations of split / parsing on the net before coming to ask, and can find something partway and dealing with it after the event in terms of database updating / repairing however not quite in terms of doing it as the user types

I want to split a postcode into two parts hidden away from the user for use elsewhere in the system in demographics reports.

The user will enter the postcode via a mask to keep things simple for them and this is to happen once they leave the field.

Its parsing it on the space between the outward and inward postcode parts as well as seperately the 1st digit of the inbound postcode part

If we take a couple of standard postcodes you'll get a better idea

txtprpostcode = "M27 4RG" to go into
txtgeopostcode ="M27"
txtlocpostcode = "M274"

txtprpostcode = "B3 4TH" to go into
txtgeopostcode ="B3"
txtlocpostcode = "B34"

I need to figure a way to do this as a routine on the current event for the form, activation event for a form as to update the whole database isn't really an option at the moment, though probably nice in the future.

I normally put non-visible fields dotted around the form to allow the use of

me.fieldname.value= x

which I find works better with access 2000's VBA, which I have to work with. rather than the INSERT command

Reply With Quote
  #2 (permalink)  
Old June 3rd, 2008, 10:37 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

So you want to split the data on the space? You would need to do this with an array.

I would put this on the Before Insert and Before Update events of your data entry form, with these fields hidden: txtgeopostcode, txtlocpostcode, then add this code:

Dim PostArray As Variant
Dim sStart As String
Dim sGeoEnd As String
Dim sLocEnd As String

sStart = Me.txtprpostcode

PostArray = Split(sStart, " ")

sGeoEnd = PostArray(0)
sLocEnd = sGeoEnd & Left(PostArray(1), 1)

Me.txtgeopostcode = sGeoEnd
Me.txtlocpostcode = sLocEnd



Did that help?



mmcdonal

Look it up at: http://wrox.books24x7.com
Reply With Quote
  #3 (permalink)  
Old June 3rd, 2008, 10:39 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

You would probably want to do something like this, though:

If IsNull(Me.txtprpostcode) or Me.txtprpostcode = "" Then
   Exit Sub
Else
'rest of code

End If

Otherwise you may get a subscript out of range error if the field is empty.

mmcdonal

Look it up at: http://wrox.books24x7.com
Reply With Quote
  #4 (permalink)  
Old June 3rd, 2008, 10:56 AM
Authorized User
 
Join Date: May 2007
Location: , , .
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hiya,

with the addition of the .value to the field names it works beautifully.

Don't know why however without the deambiguity this installation of access 2k has a fit on most things.

Reply With Quote
  #5 (permalink)  
Old July 4th, 2008, 09:33 AM
Authorized User
 
Join Date: May 2007
Location: , , .
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
Default

further to my last there seems to be a slight prob with that code in its working

I have the following input mask on the txtprpostcode box, just in case that may be a factor:

>La99\ 0LL;0;#

The issue is when the postcode has a single digit at the front

e.g. CW1 4TF will result in both having the value CW1 instead of one field having CW1 and the other having CW14

if its CW11 4RD then it works fine giving CW11 and CW114

The issue is the double space and getting the vba to recognise its there.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Parsing question: robprell Perl 2 May 28th, 2010 09:51 AM
parsing xml kri_hegde XML 5 July 24th, 2007 11:37 AM
XML Parsing SCADA_Monkey XML 2 March 11th, 2007 03:20 PM
Parsing mwviola98 SQL Language 4 July 21st, 2005 10:35 AM
Parsing in PHP Walter G Pro PHP 2 August 14th, 2003 01:54 AM



All times are GMT -4. The time now is 05:44 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.