Unbound Textbox formatted as a time format

R

Ronald Dodge

When a user clicks into a textbox, is there a way to have it so as it only
shows the time portion, not the date portion from the value property having
the full date and time value? Currently as it stands, a user click into the
textbox, and it goes from showing just the time portion to showing the date
and time both.

--

Sincerely,

Ronald R. Dodge, Jr.
Master MOUS 2000
 
M

Marshall Barton

Ronald said:
When a user clicks into a textbox, is there a way to have it so as it only
shows the time portion, not the date portion from the value property having
the full date and time value? Currently as it stands, a user click into the
textbox, and it goes from showing just the time portion to showing the date
and time both.


Not without a lot of fooling around. When a text box gets
the focus it is supposed to display the unformatted value so
you can see and edit the real data.

It almost sounds as if you want to lock the date portion and
unlock the time portion. OTOH, maybe you don't really want
the date at all.
 
R

Ronald Dodge

Yes, I have the date showing in one text box and the time of day (or night)
showing in the other text box with both of them using a date format and time
format respectively.

When I start using something, I want to learn it inside out, which I have
learned a lot of Access and I have had to create custom code to overcome
some of it's shortfalls (limitations and bugs). However, there's still
plenty more stuff for me to learn in Access and I'm hoping this isn't one of
those types of cases that I would have to create custom code, though it
wouldn't surprise me. However, if I do have to create custom code to
overcome this issue, it would still be relatively minor compared to others
that I have had to do in Access.

--

Sincerely,

Ronald R. Dodge, Jr.
Master MOUS 2000
 
M

Marshall Barton

Ronald said:
Yes, I have the date showing in one text box and the time of day (or night)
showing in the other text box with both of them using a date format and time
format respectively.

When I start using something, I want to learn it inside out, which I have
learned a lot of Access and I have had to create custom code to overcome
some of it's shortfalls (limitations and bugs). However, there's still
plenty more stuff for me to learn in Access and I'm hoping this isn't one of
those types of cases that I would have to create custom code, though it
wouldn't surprise me. However, if I do have to create custom code to
overcome this issue, it would still be relatively minor compared to others
that I have had to do in Access.


Ok. Since you already have separate text boxes for the date
and time parts, it implies that the time text box is unbound
and you are doing something (in the Current event?) to copy
the date/time value from the record source datetimefield.
In that case, you can just copy the time value instead of
the whole firld's value:
Me.timetextbox = TimeValue(Me.datetimefield)

Then use the time text box's AfterUpdate event to modify the
datetime field's value:
Me.datetimefield = DateValue(Me.datetimefield) +
TimeValue(Me.datetimefield)

You will need similar code for the date text box.

Note that if the entire value of a field as formatted by the
text box's Format property can be displayed within the
available space (text box width), then Access will
usually(?) display the formatted value instead of using its
internal formatting (in an attempt to display as much data
as it can in the available space).
 
R

Ronald Dodge

Yes, the form is unbound and so are many of the controls on the forms. I am
using unbound forms and controls as a result of the side effects that I
still have not been able to get around using bound forms and controls.
About the only thing I been able to use without the illeffects for binding
purposes is the RowSource property of the ComboBox, and possibly of a
ListBox.

I had that thought process, but given even something like 0.5 would have a
date tied to it, I didn't take that route as I thought something like
12/30/1899 12:00:00 would be more confusion than 09/19/2007 12:00:00 would
be.

I know about the form events, but given the forms are unbound, I'm using
only a limited number of those events where as I'm still using the control
events quite extensively. Some of the things are actually control via
command buttons as one of the major issues I have with Access using bound
forms, you must decide rather if you are going into edit mode, read only
mode, or add mode prior to doing anything to the form as a user, which isn't
the case to know in some cases. Not only that, but I'm having to keep the
forms to more or less act similar to how the FE program to our JDE database
acts, so as to keep confusion to a limit and keep the feel more or less the
same, even though there will obviously be some differences. Along these
same lines, I'm also using the disconnected database model to the extent
that one reasonably can use, as taught in the ADO.NET programming.

Also, given that I have custom error checking codes taking place, I'm
actually having to use the Change event on the control to format the data
prior to the data being compared against the format property, thus using the
BeforeUpdate event wouldn't work as it would error out before the event
would even be triggered. The idea is to allow the user to use just the
numpad (what I call the numpad, MS calls it as the keypad) as much as
reasonably possible so as the user doesn't waste time switching back and
forth between the numpad and the qwerty keyboard.

--

Sincerely,

Ronald R. Dodge, Jr.
Master MOUS 2000
 
M

Marshall Barton

Ronald said:
Yes, the form is unbound and so are many of the controls on the forms. I am
using unbound forms and controls as a result of the side effects that I
still have not been able to get around using bound forms and controls.
About the only thing I been able to use without the illeffects for binding
purposes is the RowSource property of the ComboBox, and possibly of a
ListBox.

I had that thought process, but given even something like 0.5 would have a
date tied to it, I didn't take that route as I thought something like
12/30/1899 12:00:00 would be more confusion than 09/19/2007 12:00:00 would
be.

I know about the form events, but given the forms are unbound, I'm using
only a limited number of those events where as I'm still using the control
events quite extensively. Some of the things are actually control via
command buttons as one of the major issues I have with Access using bound
forms, you must decide rather if you are going into edit mode, read only
mode, or add mode prior to doing anything to the form as a user, which isn't
the case to know in some cases. Not only that, but I'm having to keep the
forms to more or less act similar to how the FE program to our JDE database
acts, so as to keep confusion to a limit and keep the feel more or less the
same, even though there will obviously be some differences. Along these
same lines, I'm also using the disconnected database model to the extent
that one reasonably can use, as taught in the ADO.NET programming.

Also, given that I have custom error checking codes taking place, I'm
actually having to use the Change event on the control to format the data
prior to the data being compared against the format property, thus using the
BeforeUpdate event wouldn't work as it would error out before the event
would even be triggered. The idea is to allow the user to use just the
numpad (what I call the numpad, MS calls it as the keypad) as much as
reasonably possible so as the user doesn't waste time switching back and
forth between the numpad and the qwerty keyboard.


Not sure what you're trying to tell me here, but I did what
I think you are describing and it all worked fine for me.
Even setting the time text box's Format to hh:nn:ss allowed
me to edit the formatted value witout displaying the
12/30/1899 part.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top