Format Problem

  • Thread starter Thread starter DS
  • Start date Start date
D

DS

I can't seem to get this field TxtAdjust to format, it keeps asking for
end of statement. I tried quotes and parentheses. Didn't seem to work.
Any help appreciated.
Thanks
DS

Format(Me.TxtAdjust = DateAdd("n", 1, [TxtAdjust]),"h:nn AM/PM")
 
I can't seem to get this field TxtAdjust to format, it keeps asking for
end of statement. I tried quotes and parentheses. Didn't seem to work.
Any help appreciated.
Thanks
DS

Format(Me.TxtAdjust = DateAdd("n", 1, [TxtAdjust]),"h:nn AM/PM")

The Format() function returns a text string given a value and a
format. You're putting an assignment statement inside it - won't work
at all!

Try either

Me.TxtAdjust = Format(DateAdd("n", 1, [TxtAdjust]),"h:nn AM/PM")

or, simpler, simply set the Control Source (or DefaultValue property
if you want to edit it) of txtAdjust to

DateAdd("n", 1, [TxtAdjust])

and its Format property to "h:nn AM/PM" (assuming I understand
correctly what you're trying to accomplish).


John W. Vinson[MVP]
 
John said:
I can't seem to get this field TxtAdjust to format, it keeps asking for
end of statement. I tried quotes and parentheses. Didn't seem to work.
Any help appreciated.
Thanks
DS

Format(Me.TxtAdjust = DateAdd("n", 1, [TxtAdjust]),"h:nn AM/PM")


The Format() function returns a text string given a value and a
format. You're putting an assignment statement inside it - won't work
at all!

Try either

Me.TxtAdjust = Format(DateAdd("n", 1, [TxtAdjust]),"h:nn AM/PM")

or, simpler, simply set the Control Source (or DefaultValue property
if you want to edit it) of txtAdjust to

DateAdd("n", 1, [TxtAdjust])

and its Format property to "h:nn AM/PM" (assuming I understand
correctly what you're trying to accomplish).


John W. Vinson[MVP]
Thanks John, this worked.

Me.TxtAdjust = Format(Me.TxtAdjust = DateAdd("n", 1, [TxtAdjust]),"h:nn
AM/PM")

DS
 
Are you sure it worked?

As John says, having Me.TxtAdjust = DateAdd("n", 1, [TxtAdjust]) inside the
Format statement is wrong. What that's going to result in is a value of 0
(False), since the comparison will always be False. The formatting will be
applied to that value of 0. In other words, it's always going to return
12:00 AM, regardless of what value is in Me.TxtAdjust.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


DS said:
John said:
I can't seem to get this field TxtAdjust to format, it keeps asking for
end of statement. I tried quotes and parentheses. Didn't seem to work.
Any help appreciated.
Thanks
DS

Format(Me.TxtAdjust = DateAdd("n", 1, [TxtAdjust]),"h:nn AM/PM")


The Format() function returns a text string given a value and a
format. You're putting an assignment statement inside it - won't work
at all!

Try either

Me.TxtAdjust = Format(DateAdd("n", 1, [TxtAdjust]),"h:nn AM/PM")

or, simpler, simply set the Control Source (or DefaultValue property
if you want to edit it) of txtAdjust to

DateAdd("n", 1, [TxtAdjust])

and its Format property to "h:nn AM/PM" (assuming I understand
correctly what you're trying to accomplish).


John W. Vinson[MVP]
Thanks John, this worked.

Me.TxtAdjust = Format(Me.TxtAdjust = DateAdd("n", 1, [TxtAdjust]),"h:nn
AM/PM")

DS
 
Back
Top