Yep.. just completed it. It will now ask you as well if you want to change all the ship dates when you change one line item. For anyone interested in the whole code and save yourself some $$ from having someone else do it, here it is:
////////////////// OE Code \\\\\\\\\\\\\\\\\\\\
Private Type USER_INFO_2
usri2_name As Long
usri2_password As Long ' Null, only settable
usri2_password_age As Long
usri2_priv As Long
usri2_home_dir As Long
usri2_comment As Long
usri2_flags As Long
usri2_script_path As Long
usri2_auth_flags As Long
usri2_full_name As Long
usri2_usr_comment As Long
usri2_parms As Long
usri2_workstations As Long
usri2_last_logon As Long
usri2_last_logoff As Long
usri2_acct_expires As Long
usri2_max_storage As Long
usri2_units_per_week As Long
usri2_logon_hours As Long
usri2_bad_pw_count As Long
usri2_num_logons As Long
usri2_logon_server As Long
usri2_country_code As Long
usri2_code_page As Long
End Type
Private Declare Function apiNetGetDCName _
Lib "netapi32.dll" Alias "NetGetDCName" _
(ByVal servername As Long, _
ByVal DomainName As Long, _
bufptr As Long) As Long
' function frees the memory that the NetApiBufferAllocate
' function allocates.
Private Declare Function apiNetAPIBufferFree _
Lib "netapi32.dll" Alias "NetApiBufferFree" _
(ByVal buffer As Long) _
As Long
' Retrieves the length of the specified wide string.
Private Declare Function apilstrlenW _
Lib "kernel32" Alias "lstrlenW" _
(ByVal lpString As Long) _
As Long
Private Declare Function apiNetUserGetInfo _
Lib "netapi32.dll" Alias "NetUserGetInfo" _
(servername As Any, _
username As Any, _
ByVal level As Long, _
bufptr As Long) As Long
' moves memory either forward or backward, aligned or unaligned,
' in 4-byte blocks, followed by any remaining bytes
Private Declare Sub sapiCopyMem _
Lib "kernel32" Alias "RtlMoveMemory" _
(Destination As Any, _
Source As Any, _
ByVal Length As Long)
Private Declare Function apiGetUserName Lib _
"advapi32.dll" Alias "GetUserNameA" _
(ByVal lpBuffer As String, _
nSize As Long) _
As Long
Private Const MAXCOMMENTSZ = 256
Private Const NERR_SUCCESS = 0
Private Const ERROR_MORE_DATA = 234&
Private Const MAX_CHUNK = 25
Private Const ERROR_SUCCESS = 0&
Public FormMode As Variant
Public varfGetUserName As Variant
Public ChangeAllShipDates As Variant
Public ShipDateChange As Variant
Public DateBefore As Variant
Public DateAfter As Variant
Private Function fGetUserName() As String
' Returns the network login name
Dim lngLen As Long, lngRet As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngRet = apiGetUserName(strUserName, lngLen)
If lngRet Then
varfGetUserName = Left$(strUserName, lngLen - 1)
End If
End Function
Private Sub Enter_UserName()
Dim username_sql As Variant
Dim AccessMacola As New ADODB.Connection
Dim AccessConnStr As Variant
Call fGetUserName
AccessConnStr = "dsn=AccessToSQLHQ"
If AccessMacola.State = adStateOpen Then AccessMacola.Close
AccessMacola.Open AccessConnStr
username_sql = "UPDATE oeordhdr_sql SET oeordhdr_sql.user_def_fld_1 = '" & varfGetUserName & "' WHERE (((oeordhdr_sql.ord_no)=" & OrdNo & "))"
AccessMacola.Execute username_sql, dbFailOnError
End Sub
Private Sub ListView_GotFocus()
'Call MsgBox("ListView has Focus", vbOKOnly)
End Sub
Private Sub macForm_Close()
'Add code so time is given so Enter_UserName can run
For i = 1 To 30000
Next i
End Sub
Private Sub Order_LoseFocus(AllowLoseFocus As Boolean)
OrdNo = Trim(Order.Text)
Call ScreenStatus 'Check to see if screen is in change mode
End Sub
Private Sub ReqShip_GotFocus()
DateBefore = ReqShip.Text
End Sub
Private Sub ReqShip_LoseFocus(AllowLoseFocus As Boolean)
DateAfter = ReqShip.Text
Call ScreenStatus 'Check to see if screen is in change mode
If booIsThisOpen = True And DateBefore <> DateAfter Then
msganswer = MsgBox("Do you wish to change all line items to the changed date?", vbYesNo)
ShipDateChange = ReqShip.Text
If msganswer = 6 Then
ChangeAllShipDates = True
Else
ChangeAllShipDates = False
End If
End If
End Sub
Private Sub Type_GotFocus()
Dim username_sql As Variant
Dim AccessMacola As New ADODB.Connection
Dim AccessConnStr As Variant
If OrdNo <> "" Then
If booIsThisOpen = False Then 'Screen is not in change mode so add UserName to Order
Enter_UserName
ElseIf booIsThisOpen = True And ChangeAllShipDates = True Then 'User changed Ship Date and wants them all to change
Call fGetUserName
AccessConnStr = "dsn=AccessToSQLHQ"
If AccessMacola.State = adStateOpen Then AccessMacola.Close
AccessMacola.Open AccessConnStr
updateshipdate_sql = "UPDATE oeordlin_sql SET oeordlin_sql.req_ship_dt = '" & ShipDateChange & "' WHERE (((LTrim([ord_no]))=" & OrdNo & "))"
AccessMacola.Execute updateshipdate_sql, dbFailOnError
End If
ChangeAllShipDates = False
OrdNo = ""
End If
End Sub
///////////////// MODULE1 CODE \\\\\\\\\\\\
Global OrdNo As Variant
Declare Function EnumWindows Lib "user32.dll" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Declare Function GetWindowTextLength Lib "user32.dll" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Declare Function GetActiveWindow Lib "user32.dll" () As Long
Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Long, ByVal Msg As Long, wParam As Any, lParam As Any) As Long
Global booIsThisOpen As Boolean
Global strIsThisopen As String
Public Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
On Error Resume Next
Dim slength As Long, TitleBar As String
Dim retval As Long
Static winnum As Integer
booIsThisOpen = False
winnum = winnum + 1
slength = GetWindowTextLength(hwnd) + 1
If slength > 1 Then
TitleBar = Space(slength)
retval = GetWindowText(hwnd, TitleBar, slength)
If InStr(TitleBar, strIsThisopen) Then
booIsThisOpen = True
Exit Function
End If
End If
EnumWindowsProc = 1
End Function
Public Function ScreenStatus()
'Checks to see if screen is in Change mode.
strIsThisopen = "001 Enter Orders - [Change]"
Call EnumWindows(AddressOf EnumWindowsProc, 0)
End Function
If you have any questions, just ask. I hope others contribute their ES Flex code so others may benefit.