Assigning a field value

E

Emmweb

I'm quite certain this is an extremely simple question - I'll probably kick
myself when I hear the answer.

I have a list box (TimeEntry) of time values in 30 minute increments. (7:00
AM, 7:30 AM...)
I then have a text box (StartTime) bound to a field.

When a time is selected in the list box, I'd like that time's value
automatically assigned to the StartTime textbox and field. When I run this
code under the Click event of TimeEntry, I get a message that the Validation
Rule or BeforeUpdate properties of the control won't allow the assignment.

Dim temptime As String
temptime = Format(TimeEntry.Value, "Long time")
StartTime.SetFocus
StartTime.Text = temptime

I have looked at both controls involved and there is no Validation Rule or
BeforeUpdate event for either one. I've also tried changing the data types to
string and date both, and tried various formats. Nothing's working.

On another strange note, if you click to Debug the problem and then exit the
debugger, the value is assigned as I'd want it to be to the text box and
field.

Thanks in advance!
 
T

Terry

Access is sometimes too smart and does have some timing issues.
Try
StartTime = format(TimeEntry,"Long time")
 
J

John Vinson

I'm quite certain this is an extremely simple question - I'll probably kick
myself when I hear the answer.

I have a list box (TimeEntry) of time values in 30 minute increments. (7:00
AM, 7:30 AM...)
I then have a text box (StartTime) bound to a field.

When a time is selected in the list box, I'd like that time's value
automatically assigned to the StartTime textbox and field. When I run this
code under the Click event of TimeEntry, I get a message that the Validation
Rule or BeforeUpdate properties of the control won't allow the assignment.

Dim temptime As String
temptime = Format(TimeEntry.Value, "Long time")
StartTime.SetFocus
StartTime.Text = temptime

First off, remove the Text property: just setting StartTime to
temptime should work. You're going all around the barn! Why not just
say

StartTime = TimeEntry

and be done with it? Is the datatype of the StartTime field Date/Time?

John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 

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