Home

Macros and Programming

 

CardboxForumsMacros and Programming > "postcode macro across multiple records"

postcode macro across multiple records

Current user: [none]
Register / Log In · Help

Posted By Post

greenkeeper

28-Oct-2015 11:23

i have created a macro to open up google maps and search for the postcode which is great, how would i then apply this macro across multiple records? so that all post code searches would plot on to google maps.

bert

28-Oct-2015 12:55

Did you find how to show more than one marker on Google?

greenkeeper

28-Oct-2015 13:44

there is a way that would involve adapting the java script but that might be a little messy is there any other map providers that you would recommended for this ?

bert

28-Oct-2015 14:47

Well, I Googled... and found that it is possible to show more markers on a map - just using the address bar in your browser (url). I do not know where the limit is (yet). How many postcodes you want to show? Gathering postcodes in your Cardbox database is of course no problem.

greenkeeper

28-Oct-2015 15:03

it would be 30 -35 max, what line of code would i need to include in the macro to make this possible at the moment i use this to show a single address

x = fields("p_code")
x =replace(x," ","") 'remove spaces in postoce
launch "chrome","http://maps.google.co.uk/maps?q=" & x,cbxWindowStateMaximize

bert

28-Oct-2015 18:16

Collection the postcodes is actual a little basic and written in the Cardbox macros manual...

However:

'Collect the postcodes in my selection start at record 1
for rec = 1 to Records.count
  postcodes = postcodes & vbcrlf & Replace(Fields("POSTCODE"), " ","")
next
'the proof:
Msgbox postcodes

Variable postcodes offers you a list of all Postcodes.

bert

28-Oct-2015 18:39

'two things forgotten
'Collect the postcodes in my selection start at record 1
for rec = 1 to Records.count
  postcodes = Postcodes & Replace(Fields("POSTCODE"), " ","") & vbcrlf
  nextRecord
next
'the proof:
Msgbox postcodes

bert

28-Oct-2015 22:10

For building and URL perhaps this brings you some wisdom:
https://developers.google.com/maps/documentation/static-maps/intro

Within 2048 characters you can enter a lot of postcodes.

greenkeeper

29-Oct-2015 09:29

so would these lines of code just go under the others?

bert

29-Oct-2015 10:17

First: try whole code and see what is happening.

Change it to your needs.
(I know much better code - but for a start is this ok)

'--------------------------
'Collect the postcodes in my selection start at record 1
for rec = 1 to Records.count
  postcodes = Postcodes & Replace(Fields("p_code""), " ","") & vbcrlf
  nextRecord
next
'the proof:
Msgbox postcodes
'---------------------------

greenkeeper

29-Oct-2015 10:45

na i can't get that to work at all...
x = fields("p_code")
x =replace(x," ","") 'remove spaces in postoce
launch "chrome","http://maps.google.co.uk/maps?q=" & x,cbxWindowStateMaximize

above works for one but any other combination of the other two codes doesn't bring up anything other then an error mesage unternated string constant

bert

29-Oct-2015 11:21

apostrophe too much...
'--------------------------
'Collect the postcodes in my selection start at record 1
for rec = 1 to Records.count
  postcodes = Postcodes & Replace(Fields("p_code"), " ","") & vbcrlf
  nextRecord
next
'the proof:
Msgbox postcodes
'---------------------------

greenkeeper

29-Oct-2015 11:38

so that opens up the message box with postcodes as expected now i am stuck as to then launching these on to map system, looking at it, it should be
'the proof:
x = fields("p_code")
x =replace(x," ","") 'remove spaces in postoce
launch "chrome","http://maps.google.co.uk/maps?q=" & x,cbxWindowStateMaximize

where fields would be Msgbox
but even then i cant get that to play ball

bert

29-Oct-2015 13:06

You asked: "postcode macro across multiple records"
I send you one.
You can see all postcodes are collected of the current records in the msgbox.

Instead the msgbox line you need of course a line for launching your browser.
With your current line it is not possible to show more than one pointer as you can see on https://developers.google.com/maps/documentation/static-maps/intro.
There you can read how your url will become. I that line you need also your collected postcodes variable.

greenkeeper

29-Oct-2015 13:19

TRUE

Quick Reply

Please log in or register before trying to post a reply.

 
© 2010 Cardbox Software Limited   Home