我需要帮助找出这个公式,或者需要一个关于在ACCESS上提出更好的公式的建议

时间:2013-08-13 22:01:19

标签: forms switch-statement access-vba iif

我需要这些公式的帮助,我尝试使用这个,但它告诉我这是长期

= IIf([Combo5] =“建筑服务工程师”,[表格]![估计]![Text787],IIf([Combo5] =“Carpenter”,[表格]![估计]![Text788], IIf([Combo5] =“监护人”,[表格]![估计]![Text789],IIf([Combo5] =“监护人 - 轮班工资(早上5点 - 早上6点)”,[表格]![估计]![Text790 ],IIf([Combo5] =“电工”,[表格]![估计]![Text791],IIf([Combo5] =“设施项目主管”,[表格]![估计]![Text792],IIf( [Combo5] =“Fire Marshal”,[表格]![估计]![Text793],IIf([Combo5] =“园艺专家”,[表格]![估计]![Text794],IIf([Combo5] = “地面工人”,[表格]![估计]![Text795],IIf([Combo5] =“室内设计”,[表格]![估计]![Text796],IIf([Combo5] =“灌溉专员” ,[表格]![估计]![Text797],IIf([Combo5] =“劳动者”,[表格]![估计]![Text798],IIf([Combo5] =“铅自动/装备机械师”,[形式]![估计]![Text799],IIf([Combo5] =“主要监护人”,[表格]![估计]![Text800],IIf([Combo5] =“Lead Grounds Worker”,[表格]! [预计]![Text801] ,IIf([Combo5] =“Light Auto / Equip Operator”,[Forms]![Estimate]![Text802],IIf([Combo5] =“Locksmith”,[Forms]![Estimate]![Text803],IIf ([Combo5] =“维护技工”,[表格]![估计]![Text804],IIf([Combo5] =“画家”,[表格]![估计]![Text805],IIf([Combo5] = “害虫控制专家”,[表格]![估计]![Text806],IIf([Combo5] =“水管工”,[表格]![估计]![Text807],IIf([Combo5] =“Recycler(Laborer) )“,[表格]![估计]![Text808],IIf([Combo5] =”制冷机械师“,[表格]![估计]![Text809],IIf([Combo5] =”监督建筑服务工程师“ [表格]![估计]![Text810],0)))))))))))))))))))))))))

所以我把它作为一个SWITCH功能

= Switch([Combo5] =“建筑服务工程师”,[表格]![估计]![Text787],[Combo5] =“Carpenter”,[表格]![估计]![Text788],[Combo5 ] =“保管人”,[表格]![估计]![Text789],[Combo5] =“保管人 - 轮班工资(早上5点 - 早上6点)”,[表格]![估计]![Text790],[Combo5] = “电工”,[表格]![估计]![Text791],[Combo5] =“设施项目主管”,[表格]![估计]![Text792],[Combo5] =“消防元帅”,[表格] ![估计]![Text793],[Combo5] =“园艺专家”,[表格]![估计]![Text794],[Combo5] =“Grounds Worker”,[表格]![估计]![Text795] ,[Combo5] =“室内设计”,[表格]![估计]![Text796],[Combo5] =“灌溉专家”,[表格]![估计]![Text797],[Combo5] =“劳动者” ,[表格]![估计]![Text798],[Combo5] =“Lead Auto / Equip Mechanic”,[表格]![估计]![Text799],[Combo5] =“Lead Custodian”,[表格]! [估计]![Text800],[Combo5] =“Lead Grounds Worker”,[Forms]![Estimate]![Text801],[Combo5] =“Light Auto / Equip Operator”,[Forms]![Es timate]![Text802],[Combo5] =“Locksmith”,[Forms]![Estimate]![Text803],[Combo5] =“Maintenance Mechanic”,[Forms]![Estimate]![Text804],[Combo5 ] =“画家”,[表格]![估计]![Text805],[Combo5] =“害虫控制专家”,[表格]![估计]![Text806],[Combo5] =“水管工”,[表格]![Estimate]![Text807],[Combo5] =“Recycler(Laborer)”,[Forms]![Estimate]![Text808],[Combo5] =“Refrigeration Mechanic”,[Forms]![估计]! [Text809],[Combo5] =“监督建筑服务工程师”,[表格]![估计]![Text810])

那没用,所以我用它作为模块

Option Compare Database
Public Function fncRetValBasedOnCmb4() As String
Select Case Forms!ReportFinished!Combo4
    Case "Building Service Engineer"
        fncRetValBasedOnCmb4 = Forms!Estimate!Text787
    Case "Carpenter"
        fncRetValBasedOnCmb4 = Forms!Estimate!Text788
    Case "Custodian"
        fncRetValBasedOnCmb4 = Forms!Estimate!Text789
    Case "Custodian - Shift Pay (5am - 6am)"
        fncRetValBasedOnCmb4 = Forms!Estimate!Text790
    Case "Electrician"
        fncRetValBasedOnCmb4 = Forms!Estimate!Text791
    Case "Facilities Project Supervisor"
        fncRetValBasedOnCmb4 = Forms!Estimate!Text792
    Case "Fire Marshal"
        fncRetValBasedOnCmb4 = Forms!Estimate!Text793
    Case "Gardening Specialist"
        fncRetValBasedOnCmb4 = Forms!Estimate!Text794
    Case "Grounds Worker"
        fncRetValBasedOnCmb4 = Forms!Estimate!Text795
    Case "Interior Design"
        fncRetValBasedOnCmb4 = Forms!Estimate!Text796
    Case "Irrigation Specialist"
        fncRetValBasedOnCmb4 = Forms!Estimate!Text797
    Case "Laborer"
        fncRetValBasedOnCmb4 = Forms!Estimate!Text798
    Case "Lead Auto/Equip Mechanic"
        fncRetValBasedOnCmb4 = Forms!Estimate!Text799
    Case "Lead Custodian"
        fncRetValBasedOnCmb4 = Forms!Estimate!Text800
    Case "Lead Grounds Worker"
        fncRetValBasedOnCmb4 = Forms!Estimate!Text801
    Case "Light Auto/Equip Operator"
        fncRetValBasedOnCmb4 = Forms!Estimate!Text802
    Case "Locksmith"
        fncRetValBasedOnCmb4 = Forms!Estimate!Text803
    Case "Maintenance Mechanic"
        fncRetValBasedOnCmb4 = Forms!Estimate!Text804
    Case "Painter"
        fncRetValBasedOnCmb4 = Forms!Estimate!Text805
    Case "Pest Control Specialist"
        fncRetValBasedOnCmb4 = Forms!Estimate!Text806
    Case "Plumber"
        fncRetValBasedOnCmb4 = Forms!Estimate!Text807
    Case "Recycler (Laborer)"
        fncRetValBasedOnCmb4 = Forms!Estimate!Text808
    Case "Refrigeration Mechanic"
        fncRetValBasedOnCmb4 = Forms!Estimate!Text809
    Case "Supervising Building Service Engineer"
        fncRetValBasedOnCmb4 = Forms!Estimate!Text810
    Case Else
        fncRetValBasedOnCmb4 = 0
End Select

结束功能

事情是我不知道如何触发这个


我有一个输入数据的表单 并且我试图创建一个带有几个组合框的新表单,一旦选中它将显示未绑定文本框中的关联数量(来自第一个表单的计算字段)

1 个答案:

答案 0 :(得分:0)

如何放置公式:

=fncRetValBasedOnCmb4()

在未绑定文本框的控件来源中?