'DoCmd.ShowAllRecords 'DoCmd.FindRecord 'Add a filter function when the list(fltSalesGroup) changed. PrivateSub fltSalesGroup_Change() Dim strFilterSQL AsString Const strSQL ="SELECT * FROM FORECAST_12M WHERE STATUS=0 AND FC_PERIOD='200710' " strFilterSQL = strSQL +" AND [SalesGroup] = '"+ Me!fltSalesGroup +"'" Me.RecordSource = strFilterSQL Me.Requery End Sub 'Confirm the update action before update PrivateSub Form_BeforeUpdate(Cancel AsInteger) Dim intSelect AsInteger intSelect =MsgBox("Do you want to update this line data?", vbYesNo + vbQuestion, "Notice") If intSelect <> vbYes Then Me.Form.Undo Else Call logCustomer(Me!txtCustomerCode) EndIf End Sub '-------------------------------- 'Modules 'log the actions PublicFunction logCustomer(ByVal strCustomerCode AsString) OnErrorGoTo Err Dim conn As ADODB.Connection Dim strSQL AsString Set conn = CurrentProject.Connection strSQL ="INSERT INTO history_Customer SELECT CustomerCode, ShortName, Region, BillTo, '"& osMachineName() &"' AS InputUser, Now() AS InputTime FROM Forecast_Customer WHERE CustomerCode='"& strCustomerCode &"'" conn.Execute (strSQL) Set conn =Nothing ExitFunction Err: MsgBox Err.Number & Err.Description End Function 'To get the client machine name through Windows API Private Declare Function getComputerName_API Lib "kernel32" Alias _ "GetComputerNameA" (ByVal lpBuffer AsString, nSize AsLong) AsLong Function osMachineName() AsString Dim lngLen AsLong, lngX AsLong Dim strCompName AsString lngLen =16 strCompName =String$(lngLen, 0) lngX = getComputerName_API(strCompName, lngLen) If lngX <>0Then osMachineName =Left$(strCompName, lngLen) Else osMachineName ="" EndIf End Function
posted on
2007-11-01 12:31Sady 阅读(
...) 评论(
...)
编辑收藏