Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting Line Break in DLookup function

Status
Not open for further replies.

Aqif

Programmer
Apr 27, 2002
240
AU
Hi :)

I have got a text field which got a formula like this

=Dlookup (Dlookup1 Arguments) & " " & Dlookup(Dlookup2 Arguments)

What I want to do is to Insert a Line Break like Chr(10) between the two lookup codes. Is there any simple way to do that or do I have to write the formula in VBA and then use Chr(10) & chr(13) funnctions.

Cheers!
Aqif
 

there is a function vbCrLf

which will do this for you insert as below
Cr = carriage return from typing days when the roller was
called a carriage and returning it to the left to
start a new line
Lf = Line feed - speaks for itself


=Dlookup (Dlookup1 Arguments) & vbCrLf & Dlookup(Dlookup2 Arguments)
 
I tried using that but when I write the formula in the control box of my text box then access formats the formula like =Dlookup(Dlookup1 Arguments) & [vbCrLf] & Dlookup(Dlookup2 Arguments)

And the result of the formula is #Name error :(

Any suggestions????

Cheers!
Aqif
 
hi Aqif

it will cos [VBCRLF] is passing an unkown field into the equation and it wont know what you are talking about

=Dlookup (Dlookup1 Arguments) & vbCrLf() & Dlookup(Dlookup2 Arguments)



if it comes back with unknown function then put the code below in a module

function vbcrlrf()
vbcrlf = chrs(10) & chr$(13)
end function
that should resolve it


jo
 
Hi :(

Thanxx for ur tip but that stupid thing still shows boxes type chracters between the tow words instead of a line break...:( it's really driving me mad :(

Cheers!
Aqif
 
I think your just getting the Char codes the wrong way round. Use:
Chr$(13) & Chr$(10)
inbetween your two dlookups instead of:
Chr$(10) & Chr$(13)

Hope this works,

starsky51
 
vbCrLf isn't a function. it's an intrinsic constant.

Hence just vbCrLf, not vbCrLf()

Craig
 
Hello,

The following works for me and returns

Gary
Andy

MsgBox DLookup("FName", "tblFamily", "FamilyID = " & 1) _
& vbCrLf _
& DLookup("FName", "tblFamily", "FamilyID = " & 3)

Good Luck!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top