Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

On Exit Event Requery? 1

Status
Not open for further replies.

Asspin

Technical User
Jan 17, 2005
155
US
I wasn't entirely sure where to put this post, but here goes anyway. I have 2 text boxes on this form, on top of each other. What I am doing, is displaying one text box which has a time in it, but when it gets focus, it moves the focus to the other box which has the time in seconds. The time in seconds is what the user is to be updating. Then when the textbox loses focus it should switch back to the the time box, which gives an easier to view display of the data.

Any ideas on how to get this to work would be great.

As it sits right now, it works, but you have to save the form after a change, then click on and off of the textboxes again.

Code:
Private Sub dForecastAHTT1_Exit(Cancel As Integer)
    Dim AHT As Single
    AHT = dForecastAHTT1
    AHT = AHT / 24 / 60
    DoCmd.SetWarnings False
    DoCmd.RunSQL "UPDATE tData SET dForecastAHTT1Time =" & AHT
    DoCmd.Requery "dForecastAHTT1Time"
    DoCmd.SetWarnings True
    dForecastAHTT1Time.Visible = True
End Sub

Code:
Private Sub dForecastAHTT1Time_GotFocus()
    dForecastAHTT1.SetFocus
    dForecastAHTT1Time.Visible = False
End Sub

Dan
 
You may try to replace this:
DoCmd.Requery "dForecastAHTT1Time"
with this:
Me.Refresh

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
That works the same as what I had, still have to save it, and it gives me a "write conflict error" saying another user has made a change to the data. (I assume this is caused by the SQL.

Dan
 
Is there a way to do a save and suppress the error message perhaps?

Dan
 
So, why not simply replace this:
DoCmd.RunSQL "UPDATE tData SET dForecastAHTT1Time =" & AHT
with this ?
Me!dForecastAHTT1Time = AHT

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Awesome answer as always, works perfect! I can't believe I missed that!

Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top