I have a VB script in MS Access that takes data from a table and populates it to myscreen.com, inserts new criteria into the screen, and updates the record. This works fine for one record at a time. I added a loop to the VB script and set the counter at 2 to test. The first record populates to the screen and updates fine. The second record won't populate until I go back and click anywhere on the MS Access application (and not the macro button.) Any ideas as to why the loop won't run without user intervention? Here's my code.
Private Sub cmdKeyRecord_Click()
Dim LoopCounter As Integer
LoopCounter = 2
While LoopCounter < 4
DoCmd.GoToRecord , , acFirst
AppActivate "myscreen.com", True
SendKeys "{F7}", True
SleepX (1000)
SendKeys Me.Area, True
If Len(Me.Area) <> 5 Then
SendKeys "{TAB}", True
End If
SendKeys Me.PO, True
If Len(Me.PO) <> 7 Then
SendKeys "{TAB}", True
End If
SendKeys Me.Item1, True
If Len(Me.Item1) <> 4 Then
SendKeys "{TAB}", True
End If
SendKeys Me.Item2, True
If Len(Me.Item2) <> 4 Then
SendKeys "{TAB}", True
End If
SendKeys "{F8}", True
SleepX (2000)
SendKeys "+{TAB 4}", True
SendKeys Me.MFG, True
If Len(Me.MFG) <> 3 Then
SendKeys "{TAB}", True
End If
SendKeys Me.NewModel, True
If Len(Me.NewModel) <> 8 Then
SendKeys "{TAB}", True
End If
SendKeys Me.MY, True
SendKeys "{END}", True
SendKeys "+{TAB}", True
SendKeys Me.RequestedBy, True
If Len(Me.RequestedBy) <> 16 Then
SendKeys "{TAB}", True
End If
SendKeys Me.Reason, True
SendKeys "{F6}", True
SleepX (2000)
SendKeys "{F7}", True
DoCmd.Requery
LoopCounter = LoopCounter + 1
Wend
End Sub


