ACCESS FORM设计积累

' DoCmd.ShowAllRecords
'
DoCmd.FindRecord

' Add a filter function when the list(fltSalesGroup) changed. 
Private   Sub  fltSalesGroup_Change()
  
Dim  strFilterSQL  As   String
  
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
Private   Sub  Form_BeforeUpdate(Cancel  As   Integer )
  
Dim  intSelect  As   Integer
  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)
  
End   If  
End Sub

' --------------------------------
'
Modules
'
log the actions
Public   Function  logCustomer(ByVal strCustomerCode  As   String )
  
On   Error   GoTo  Err
    
Dim  conn  As  ADODB.Connection
    
Dim  strSQL  As   String
        
    
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
    
Exit   Function

  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  As   String , nSize  As   Long As   Long

Function  osMachineName()  As   String
  
Dim  lngLen  As   Long , lngX  As   Long
  
Dim  strCompName  As   String

  lngLen 
=   16
  strCompName 
=   String $(lngLen,  0 )
  lngX 
=  getComputerName_API(strCompName, lngLen)
    
  
If  lngX  <>   0   Then
    osMachineName 
=   Left $(strCompName, lngLen)
  
Else
    osMachineName 
=   ""
  
End   If
End Function
posted on 2007-11-01 12:31 Sady 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/sady/archive/2007/11/01/945536.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值