concatenate

A

accessuser1308

I currently have the following code to concatenate a couple of fields on a
form into a new field:

If IsNull([NameDate]) Then
[NameDate] = [Name] & ", " & Date
Else
[NameDate] = ", " & [SampleName] & ", " & Date
End If

My question is...
Can this code be modified such that the first field will be on line 1, the
second field concatenated to a second line, etc...with each subsequent
addition to the concatenate going on a new line? Or is there better code
that can be used to accomplish this?

Basically I want the new field to have data in the following format...

Field 1
Field 2
Etc

Thank you for your help
 
D

Douglas J. Steele

Assuming you want Name and Date on one line, and SampleName and Date on
another line,

If IsNull([NameDate]) Then
[NameDate] = [Name] & ", " & Date
Else
[NameDate] = vbCrLf & [SampleName] & ", " & Date
End If

If you want Name on one line, Date on another line, SampleName on a third
line and Date on a fourth line,

If IsNull([NameDate]) Then
[NameDate] = [Name] & vbCrLf & Date
Else
[NameDate] = vbCrLf & [SampleName] & vbCrLf & Date
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top