My dates don't show up immediately in text boxes

dcx693

Registered User.
Local time
Today, 16:57
Joined
Apr 30, 2003
Messages
3,265
I've got a form with a textbox. Next to the textbox is a command button. This is the code in the click event of the command button:
Me.txtEnteredDate = Now()
The code works.

My problem: sometimes the textbox immediately shows today's value. Other times, I need to switch to another screen, then back in order to show the update in the text box.

What is going on here? Anybody have any ideas? Thanks.

I'm using Access 2000 (which could be the problem right there) on Windows NT 4.0 sp6.
 
DCX,

Any chance of an example.

Just curious, but the other screen is it within access or is it another application?

Andy
 
Thanks for the reply spacepro.

Through further testing, I was able to determine:
(1) the form is simply not redrawing itself. If I partially drag the Access database window over the field, let it go, then drag it away, I get a partially refreshed control.

I've attached a picture of that partial redraw. I originally had 01/17/2004, I clicked the command button to enter today's date. I then dragged the database winow partially over the field, then dragged it away.

I know that the control is actually receiving the value of today's date because I built another command button to Msgbox the current value of the control, and it said "01/30/2004".


(2) I've tested the code out on a blank new form in Access 2000, and it works fine.

It might be interesting to note that elsewhere in my main form, I've got a Microsoft Forms 2.0 Listbox control on there. Would that affect the screen redraw?
 

Attachments

  • partial_redraw.jpg
    partial_redraw.jpg
    2.9 KB · Views: 125
Last edited:
Will this help?

txtEnteredDate = Now()
DoCmd.RepaintObject acForm, Me.Name
 
DCX,

Always willing to help, I know you have helped me many a time.

Anyway is the form modal?

if so i think the form won't repaint properly if their is an activex control on the form.

if not then i honestly don't know.

hth

Andy
 
Nope, ghudson, no effect.

I had previously tried a:
Me.Repaint
also with no effect.

The form will redraw if I do a:
Me.Refresh
but the problem is that I'm entering this data into a new record, and it attempts to save the record. That would be fine except that I have fields that are required to be filled in, and I get an error message.
 
how about

txtEnteredDate = Now()
txtEnteredDate.Requery
 
OK, I feel stupid!I posted a simplified example that, of course, was correct. The actual code in my database was:
Me.Controls(strControl)=Now()
and I was passing strControl as "EnteredDate", not as "txtEnteredDate".

That obviously explains why a Me.Refresh worked.

I'm still a bit confused at to why the screen would redraw when I flipped away from Access or dragged something on top of the field though.... Yes, the controls were bound but the records were never saved in between screen flips..:confused:

Oh well, this penguin is sorry to have sent you guys on a wild goose chase.
 

Users who are viewing this thread

Back
Top Bottom