RE: erratic format result

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



actually, even your coding doesn't work properly either. When I use suggested
coding, which is same as I was usuing, as control source for the control on
my envelope, I get following two strange situations.
If zipcode is all 9 digits, and I use format 00000\-0000, then I get correct
result.But if zipcode is only 5 digits, then I get result like "00001-0598"
for zipcode that should read "10598".

If I use 00000\-9999, then this works right for 5-digit code, but
gives"782659769-9999 for 9-digit code.
I find that to bypass the problem, I'm using :
If Len(DLookup("[Zip]", "Insaddresses", "[AddIndex] = " & [AddIndex])) =5
Then
Me.Zip = DLookup(DLookup("[Zip]", "Insaddresses", " [AddIndex] = " &
[AddIndex])
ElseIf Len(DLookup("[Zip]", "Insaddresses", "[AddIndex] = " & [AddIndex])) =
9 Then
Me.Zip = DLookup(Format(DLookup("[Zip]", "Insaddresses", " [AddIndex] = " &
[AddIndex]), "00000\-0000")
End if
The above works, but I still can't figure out the problem with my table data
which causes the confusion.

"Jim Burke in Novi" wrote:

Without being able to look at your tables and your code I can't tell you why
you'd get that erratic behavior, but if you print the zip codes using the
Format I showed it should work every time - like I said, InputMask is only
for input/display on a form, it doiesn't have any effect when printing a
report. Try the format and see what happens. Normally with a nine digit zip
code you would define a text field with a length of 9 and with your Input
mask, then when printing you would use the Format function as I showed it. Is
it possible that you had some zip codes defined before you had the input mask
defined and some were entered with a '-'?

"MarinaW" wrote:

Jim, maybe you didn't understand what i meant by erratic behavior. the
hyphen appears in the zip code when printed for some addresses, and it
doesn't for others.
MW

"Jim Burke in Novi" wrote:

Input mask doesn't work for printing purposes, only for data entry. If you
want them to print that way, use the Format function:

Format(DLookup("[Zip]", "Insaddresses", " [AddIndex] = " &
[AddIndex]),"00000-9999")

"MarinaW" wrote:

I have table with ZipCodes, whech have InputMask = "00000\-9999" .
When I try to print the zipcode on an envelope, it is erratically appearing
without the hyphen in the 9 digit code.
My code for printing is:
DLookup("[Zip]", "Insaddresses", " [AddIndex] = " & [AddIndex])
All of codes are entered by means of controls on data entry forms whose
InputMask is the same as mentioned above
Anyone have any idea why this erratic behavior, or how to correct?
.



Relevant Pages

  • Re: erratic format result
    ... not all of the world needs to be able to format nine character zip ... I've always stuck with five digits, ... If zipcode is all 9 digits, and I use format 00000\-0000, then I get ... it doiesn't have any effect when printing ...
    (microsoft.public.access.modulesdaovba)
  • Re: Time Format - Need all 4 digits shown
    ... by using the Format function, depending on what you're trying to do. ... in Control Panel and change the description of Short Date to give you all ... Example Format property for a control: ... > but I need all 4 digits to show. ...
    (microsoft.public.access.gettingstarted)
  • Re: Input masks
    ... Check out the Format Property in Help. ... an Input Mask. ... > table for that control, ... > 10 digits that comprise the telephone number. ...
    (microsoft.public.access.forms)
  • Format quirks
    ... I am trying to use format to display a set of real numbers in a particular number of digits. ... I can control the size of the decimal part to 2 digits. ...
    (comp.lang.tcl)
  • Re: Format a textcontrol!
    ... Format the number when it is entered and store the formatted number. ... Store just the digits (the KeyPress event can be used to stop the user entering ... >>> In the AfterUpdate_Event of the control in which IŽd like to format the ...
    (microsoft.public.access.formscoding)