simple textbox data source syntax question

  • Thread starter Thread starter Mark Kubicki
  • Start date Start date
M

Mark Kubicki

Would someone please take a look over my shoulder? I've got the following
code entered as the data source for a text box on a report; but even in it's
simplest state, returns #error#

the intent of the code is to truncate the text at it's first hard return

=mid([CatalogNoMod],1,nz(instr(1,[CatalogNoMod],chr(10)),len([CatalogNoMod])))


any thought would be greatly appreciated in advance
thanks,
mark
 
Try the following

=Mid([CatalogNoMod],1,Instr(1,[CatalogNoMod] & Chr(10),Chr(10))-1)

I might be looking for Chr(13) instead of Chr(10) since Access usually stores
Chr(13) & Chr(10) [in that order] to generate a new line.

Also make sure that the name of the textbox control is NOT CatalogNoMod. That
will cause an error

By the way
instr(1,[CatalogNoMod],chr(10))
Is NOT going to return null if Chr(10) is not in the string. It is going to
return zero. It will return NULL if CatalogNoMod is Null


John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County
 
Back
Top