Hm, I'm trying to implement this ... What is this [Field] in the equation?
Does that correspond to the field that I want to apply this too? But it
would be better if that was a variable!
I've got 10 fields in one query that need to have a fixed number of
characters (and empty spaces if necessary to get to that fixed number).
Ideally I could use a query like this
SELECT FixFieldLength(Nz([field1], 10)) As FixedField,
FixFieldLength(Nz([field2], 5)) As FixedField2,
FixFieldLength(Nz([field3], 30)) As FixedField3 FROM myTable
Is that possible? And what's this 'Nz'?
Thanks!
Jerome
Stefan said:
hi Jerome,
Let's say I need to make a query that results in fixed length fields.
How would I tell the query to add the necessary empty spaces (if the
value in the field is less then the fixed number of characters)?
I guess it's kind of an anti-Trim: TRIM([field])
Place it in a standard module:
Public Function FixFieldLength(AString As String, _
ALength As Long) As String
FixedFieldLength = Left( _
Trim(Left([Field], ALength)) & _
Space(ALength), _
ALength _
)
End Function
You can use it in any query, e.g.
SELECT FixFieldLength(Nz([yourField], "")) As FixedField
FROM [yourTable]
mfG
--> stefan <--