CreateObject fails in Runtime (2 Viewers)

DNewman

Registered User.
Local time
Today, 11:18
Joined
Oct 12, 2012
Messages
60
I am using Access 2010 on Windows XP/Windows 7
My code converts individual lines of address (strings) into a single RTF Address field. It runs fine in full access but (as MS admits) CreateObject
does not work in Runtime.
Is there another way of doing this that avoids CreateObject??

'create AddressFull
strAddressFull = ""
If Nz(mAddress1, "") <> "" Then strAddressFull = mAddress1
If Nz(mAddress2, "") <> "" Then strAddressFull = strAddressFull & Chr(10) & mAddress2
If Nz(mAddress3, "") <> "" Then strAddressFull = strAddressFull & Chr(10) & mAddress3
If Nz(mAddress4, "") <> "" Then strAddressFull = strAddressFull & Chr(10) & mAddress4
If Nz(mAddress5, "") <> "" Then
strAddressFull = strAddressFull & Chr(10) & mAddress5 & " "
& Me.Postcode
Else
strAddressFull = strAddressFull & Chr(10) & Me.Postcode

End If

Set ThisApplication = CreateObject("Access.Application")

Me.AddressFull = ThisApplication.HtmlEncode(strAddressFull)

Any help gratefully received.
 

spikepl

Eledittingent Beliped
Local time
Today, 12:18
Joined
Nov 3, 2010
Messages
6,142
You really ought invest the time to learn how to find stuff in google - more efficient than rolling your own. There is a routine CanShrinkLines which takes address data and compacts it all into one field.

And yes, there is a way of gettinn another db open and running, but you seem here to use it as a utility, in which case you might instead want to include that db's accde as a reference. If you put it in the same folder as the original db, then you should not have probelms with distiribution.

What exactly is going on in addition to what you have shown?
 

DNewman

Registered User.
Local time
Today, 11:18
Joined
Oct 12, 2012
Messages
60
Thank you Spikepl - I did invest time in looking for solutions on the web but did not find any! T
he point is not simply that I want to put the whole address into one field but that I want to allow users to, for example, high-light the postal town so I need (at least I think I need) it to be .RTF (HTML).
Am I missing something here??
 

vbaInet

AWF VIP
Local time
Today, 11:18
Joined
Jan 22, 2010
Messages
26,374
Fyi, you're running in native Access so you don't need to create another instance of Access. Just do:
Code:
Me.AddressFull = [B][COLOR="Blue"]Application[/COLOR][/B].HtmlEncode(strAddressFull)
 

DNewman

Registered User.
Local time
Today, 11:18
Joined
Oct 12, 2012
Messages
60
Many thanks vbaInet - I think you have hit the button!
I will remove the offending line.
 

Users who are viewing this thread

Top Bottom