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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access Code ignored except when stepping through... very confused. 1

Status
Not open for further replies.

CptCrusty1

Programmer
Feb 17, 2005
216
US
I have a chunk of code that works for the most part. Its essentially a GUI that gives the user a status/update based on whats happening. Very simple, no problem solving.

1.populate text box with start time.
2.Post a message in another text box saying "TIME:Query x is starting"
3.kick off the query
4.Calculate elapsed time after the query and display in another text box.
5.repeat steps 2-4 for each query that runs.

In step 2, the message is in a variable and concatenated with a "vbcrlf" function so that the text box gives a running total.

When I step (F8) through the code, everything works great. However, when I just run it, Parts get skipped. For instance, the first lines reset all the text boxes to null values. This doesn't seem to happen at all.

Any ideas? Here's a snippet of code. Like I said, very simple.

Code:
Private Sub cmdStart_Click()
'written and designed by Richard Kline
'code started 05/08/06
'last update 05/08/06

Dim strMemo As String
Dim strElapsed As String




'DoCmd.SetWarnings False

'clean out text boxes
With Me
.txtRegMsg = ""
.txtNoPlanMsg = ""
.txtPlanMsg = ""
.txtProgressMsg = ""
.txtElapsedTime = ""
End With

'Set Status Messages
Me.txtRegMsg = "PENDING"
Me.txtNoPlanMsg = "PENDING"
Me.txtPlanMsg = "PENDING"

'set start time
Me.txtStartTime = Now()

'Run Time Keeper Query - Future idea, update with start time instead.
DoCmd.OpenQuery "qry_StartTime", acNormal, acEdit
    
'set Progress Notes.
strMemo = DateTime.Time & ": Creating Local Demand Info Table"
Me.txtProgressMsg = strMemo

'set elapsed time
strElapsed = TimeValue(Me.txtStartTime) - DateTime.Time
Me.txtElapsedTime = Hour(strElapsed) & ":" & Minute(strElapsed) & ":" & Second(strElapsed)

'run query
DoCmd.OpenQuery "qryMT_MakeLocalDemandTable", acNormal, acEdit

'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
'send next progress message.
strMemo = strMemo & vbCrLf & DateTime.Time & ": Creating BPO Tables"
Me.txtProgressMsg = strMemo

'set elapsed time
strElapsed = TimeValue(Me.txtStartTime) - DateTime.Time
Me.txtElapsedTime = Hour(strElapsed) & ":" & Minute(strElapsed) & ":" & Second(strElapsed)

'run query
DoCmd.OpenQuery "qryCSQ_FindMaxLoanBPO_LT20k", acNormal, acEdit
DoCmd.OpenQuery "qryCSQ_FindMaxLoanBPO_20_25k", acNormal, acEdit

'set elapsed time
strElapsed = TimeValue(Me.txtStartTime) - DateTime.Time
Me.txtElapsedTime = Hour(strElapsed) & ":" & Minute(strElapsed) & ":" & Second(strElapsed)

'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
'send next progress message.
strMemo = strMemo & vbCrLf & DateTime.Time & ": Starting TEST REG Process"
Me.txtProgressMsg = strMemo

'indicate REG Process Running
Me.txtRegMsg = "RUNNING"

'send next progress message.
strMemo = strMemo & vbCrLf & DateTime.Time & ": Running X1 - Create TRFC1"
Me.txtProgressMsg = strMemo

'set elapsed time
strElapsed = TimeValue(Me.txtStartTime) - DateTime.Time
Me.txtElapsedTime = Hour(strElapsed) & ":" & Minute(strElapsed) & ":" & Second(strElapsed)

DoCmd.OpenQuery "x1 ready for fcl review no payments", acNormal, acEdit

'set elapsed time
strElapsed = TimeValue(Me.txtStartTime) - DateTime.Time
Me.txtElapsedTime = Hour(strElapsed) & ":" & Minute(strElapsed) & ":" & Second(strElapsed)
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

'DoCmd.SetWarnings True
Exit Sub
Any ideas?



I live to work and I work to live.
 
I've normally seen problems like this in the form load event. In that case inserting doevents in the problem areas normally fixes it. I've never encountered this problem with a click event, so it does seem odd. You still may want to see if doevents helps. Place a doevents directy after each section of code that gets skipped.
 
I'll try that too. Something else I tried was putting a docmd.setwarnings false/true before and after each docmd.openquery I THINK that might have fixed it.

Lets see what happens.

Thanks Dude(ette)

Crusty.

I live to work and I work to live.
 
The doevents function did the trick. Thanks for that tip. I'll give you a star...

Crusty

I live to work and I work to live.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top