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

Having a problem doing something in flexibility 1

Status
Not open for further replies.

pronet74

MIS
Mar 9, 2004
192
US
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
 
Oh btw, disregard the selecttext function. I had to do it this way, because it was giving me an error if I were to try to do a setfocus command. I'm using 7.5.103e
 
Nevermind.. Fixed my own problem.. Ugh..

Had to change:

If OE0101.macForm.mode = Change Then
If Completed = True Then
SendKeys "{ESC}"
End If
End If
End Sub

to:

If OE0101.macForm.mode = Change Then
Completed=True
SendKeys "{ESC}"
End If
End Sub
 
Just a note for you.

If you would indent your vb code it would be easier to read and follow

for instance.

If OE0101.macForm.mode = Change Then
If Completed = True Then
SendKeys "{ESC}"
End If
End If

would be easier to follow if it was in the generally accepted format of

If OE0101.macForm.mode = Change Then
If Completed = True Then
SendKeys "{ESC}"
End If
End If

This way you can follow visually the IF's, withs, subs, end subs, etc.

Just some free advice.

Andy

Andy Baldwin
 
I'm giving you a star because I learned something valuable from you today. I have never heard of or seen the LockWindowUpdate API function in use before today. Very useful.

Scott Travis
infoSpring, LLC.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top