Merging Text fields

crosmill

Registered User.
Local time
Today, 12:29
Joined
Sep 20, 2001
Messages
285
I want the address fields on my DB to be merged on a form (in row format) so that they can be copy and pasted. Does anyone know how this can be done?
 
I dont know if this will work but its woth a try.
Set up your FullAddress field as a memo

code as follows
dim cr As String
cr = Chr(13) 'Chr(13) is carriage return
Me.FullAddress = Me.Address1 & cr & Me.Address2 & cr & Me.Address3 etc

or
Me.FullAddress = Me.Address1 & VbCrLf & Me.Address2 & VbCrLf & Me.Address3 etc
 
I want to reference the Address straight from the table. I've been trying "Tables![Address].[Address 1]" but it won't let me. Can I do it this way or will I have to put the indivdual fields on the form and then hide them?

Thanks

I can get it to work from txtBoxes on my form but I think Chr(13) is incorrect I have a line similar to capital I instead of a carriage return.

Is it wrong or doesn't it work.

Thanks again

[This message has been edited by crosmill (edited 11-07-2001).]
 
OK, I'm probably missing something here, but couldn't you set up a text box (named something like txtLONG_ADDR) with a control source like:
=[ADDR_LINE1] & " " & [ADDR_LINE2]

You might want to do some editing, too:
=Trim([ADDR_LINE1] & " " + Trim([ADDR_LINE2])

That "+" sign is intentional; it puts the space in there only if there's something in ADDR_LINE2
 
Add all the fields you want to combine into the query your form is based on. You do not have to set up controls for those fields, jus add them to the query, just use a text box for the FullAddress. You can now refer to them as Me("Address 1"), Me("Address 2") etc (PS it is best not to have spaces in your field names). If VbCfLf doesn't work (It does in 2000 but I'm not sure about 97) then use cr = Chr(13) & Chr(10) or replace cr in the expression with Chr(13) & Chr(10).

Another way is to use an expression in the query to the same effect. In your query, set one of the fields to FullAddress: [Address 1] & Chr(13) & Chr(10) & [Address 2] etc, making sure that the fields you want to combine are in the query otherwise it will ask you for them and then set up a form control eg txtFullAddress based upon the FullAddress expression.
 
Finally got to the end of.

I used the Chr(13) & Chr(10) (carriage Return and Line Break) to get the new line, and then referenced the address lines using DLookUp as the text was from another table.

Thanks for you help guys

[This message has been edited by crosmill (edited 11-08-2001).]
 

Users who are viewing this thread

Back
Top Bottom