My company wants me to have all the line item dates in OE, update to the ship date. I have the following code in place. It'll go through all the line items but then it basically freezes until I hit the stop button. Maybe one of you guys can help me figure out what is wrong.
Declare Function SendMessage Lib "User32" _
Alias "SendMessageA" _
(ByVal hWnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long
Const EM_SetSel = &HB1
Public Completed As Variant
Public MsgAnswer As Variant
Public ShipDateChange As Variant
Public ListCountItems As Variant
Private Declare Function LockWindowUpdate Lib "User32" _
(ByVal hWnd As Long) As Long
Private Sub SelectText(ByRef TextBox As macEditBox)
Dim iStrLen As Long
iStrLen = Len(TextBox.Text)
' Send Windows API Message to TextBox to select all the text in the TextBox
SendMessage TextBox.hWnd, EM_SetSel, 0, iStrLen
End Sub
Private Sub BILLNAME_GotFocus()
If OE0101.macForm.mode = Change Then
MsgAnswer = MsgBox("Do you wish to change all line items to the changed date?", vbYesNo)
ShipDateChange = ShipDate.Text
Completed = False
End If
End Sub
Private Sub DiscPct1_GotFocus()
If OE0101.macForm.mode = Change Then
If MsgAnswer = 6 And Completed = False Then
LockWindowUpdate macForm.hWnd
ReqShip.SetFocus
End If
End If
End Sub
Private Sub ItemNo_GotFocus()
If OE0101.macForm.mode = Change Then
If Completed = True Then
SendKeys "{ESC}"
End If
End If
End Sub
Private Sub ListBox_GotFocus()
If OE0101.macForm.mode = Change Then
ListCountItems = ListBox.Count
If MsgAnswer = 6 And Completed = False Then
SendKeys "{Enter}"
Else
Completed = True
End If
End If
End Sub
Private Sub ReqShip_GotFocus()
If OE0101.macForm.mode = Change Then
If MsgAnswer = 6 And Completed = False Then
If I + 2 < ListCountItems Then
DateLength = Len(ShipDateChange)
For J = 1 To DateLength
If Mid(ShipDateChange, J, 1) <> "/" Then
datekey = datekey + Mid(ShipDateChange, J, 1)
End If
Next J
I = I + 1
SendKeys (datekey)
SendKeys "{Enter}"
LockWindowUpdate 0
Else
Completed = True
'SendKeys "{ESC}"
'LockWindowUpdate 0
End If
End If
End If
End Sub
Private Sub ReqShip_LoseFocus(AllowLoseFocus As Boolean)
If OE0101.macForm.mode = Change Then
If Completed = True Then
SendKeys "{ESC}"
End If
End If
End Sub
Declare Function SendMessage Lib "User32" _
Alias "SendMessageA" _
(ByVal hWnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long
Const EM_SetSel = &HB1
Public Completed As Variant
Public MsgAnswer As Variant
Public ShipDateChange As Variant
Public ListCountItems As Variant
Private Declare Function LockWindowUpdate Lib "User32" _
(ByVal hWnd As Long) As Long
Private Sub SelectText(ByRef TextBox As macEditBox)
Dim iStrLen As Long
iStrLen = Len(TextBox.Text)
' Send Windows API Message to TextBox to select all the text in the TextBox
SendMessage TextBox.hWnd, EM_SetSel, 0, iStrLen
End Sub
Private Sub BILLNAME_GotFocus()
If OE0101.macForm.mode = Change Then
MsgAnswer = MsgBox("Do you wish to change all line items to the changed date?", vbYesNo)
ShipDateChange = ShipDate.Text
Completed = False
End If
End Sub
Private Sub DiscPct1_GotFocus()
If OE0101.macForm.mode = Change Then
If MsgAnswer = 6 And Completed = False Then
LockWindowUpdate macForm.hWnd
ReqShip.SetFocus
End If
End If
End Sub
Private Sub ItemNo_GotFocus()
If OE0101.macForm.mode = Change Then
If Completed = True Then
SendKeys "{ESC}"
End If
End If
End Sub
Private Sub ListBox_GotFocus()
If OE0101.macForm.mode = Change Then
ListCountItems = ListBox.Count
If MsgAnswer = 6 And Completed = False Then
SendKeys "{Enter}"
Else
Completed = True
End If
End If
End Sub
Private Sub ReqShip_GotFocus()
If OE0101.macForm.mode = Change Then
If MsgAnswer = 6 And Completed = False Then
If I + 2 < ListCountItems Then
DateLength = Len(ShipDateChange)
For J = 1 To DateLength
If Mid(ShipDateChange, J, 1) <> "/" Then
datekey = datekey + Mid(ShipDateChange, J, 1)
End If
Next J
I = I + 1
SendKeys (datekey)
SendKeys "{Enter}"
LockWindowUpdate 0
Else
Completed = True
'SendKeys "{ESC}"
'LockWindowUpdate 0
End If
End If
End If
End Sub
Private Sub ReqShip_LoseFocus(AllowLoseFocus As Boolean)
If OE0101.macForm.mode = Change Then
If Completed = True Then
SendKeys "{ESC}"
End If
End If
End Sub