组合框的默认值

时间:2012-03-22 19:37:01

标签: ms-access

我的查询表copyQuery Soil Condition有一列,我需要以另一种形式制作组合框soil_cond,默认值为Soil Condition来自copyQuery

组合框soil_cond有三个值而不是查询。

所以我尝试了这个并输入以下组合框soil_cond的默认值,但它不起作用。

=DLookUp("[Soil Condition]","copyQuery","soil_cond = [Soil Condition]")

行来源为"Backfill";"Insitu"
控制来源为Soil Condition

copyQuery是此代码中的表格:

Private Sub copy_record_Click()
  Dim query As String
  Dim qdfNew As QueryDef
  Dim dbLib As Database
  Set dbLib = CurrentDb()

  query1 = "Reference.Record_Num, Reference.[Report_Num], " & _
           "Reference.[Title], Reference.[Report_Date], " & _
           "Reference.[Author], Reference.[Organization], " & _
           "Reference.[Test Org], Reference.[Test Name], " & _
           "Reference.[Test Date], Reference.[POC]"

  query2 = "Soil_Properties.[Soil Condition], Soil_Properties.[USCS_Code]," & _
           "Soil_Properties.[Soil_C_Method], " & _
           "Soil_Properties.[Soil Compaction Method]," & _
           "Soil_Properties.[Custom Soil Compaction Method], " & _
           "Soil_Properties.[General Soil Classification], " & _
           "Soil_Properties.[Water Content Expedient], " & _
           "Soil_Properties.[Dry Density Expedient], Soil_Properties.[LL]," & _
           "Soil_Properties.[PL], Soil_Properties.[PI], " & _
           "Soil_Properties.[Per_Gravel], Soil_Properties.[Per_Sand], " & _
           "Soil_Properties.[Per_Clay], Soil_Properties.[Per_Silt], " & _
           "Soil_Properties.[Water_Cont], Soil_Properties.[Procedure 1], " & _
           "Soil_Properties.[Wet_Dens], Soil_Properties.[Procedure 2], " & _
           "Soil_Properties.[Dry_Dens], Soil_Properties.[Procedure 3]," & _
           "Soil_Properties.[Dens_Units], Soil_Properties.[Spec_Gravity]," & _
           "Soil_Properties.[Gradation Curve File], " & _
           "Soil_Properties.[Compaction Curve File]"

  query3 = "Charge_Type.[Charge_Type],Charge_Type.[Charge_Comp]," & _
           "Charge_Type.[General_Purpose_Bomb_Type], " & _
           "Charge_Type.[Artillery Round Type], " & _
           "Charge_Type.[Mortar Round Type]," & _
           "Charge_Type.[Charge_Shape], Charge_Type.[Charge_Length], " & _
           "Charge_Type.[Charge_Width], Charge_Type.[Charge_Thickness], " & _
           "Charge_Type.[Charge_Radius], Charge_Type.[Charge_Weight], " & _
           "Charge_Type.[Weapon_Category], Charge_Type.[Cased?], " & _
           "Charge_Type.[Case_Type], Charge_Type.[Case_Length], " & _
           "Charge_Type.[Case_In_Dia], Charge_Type.[Case_Thick], " & _
           "Charge_Type.[Case_Weight]"

  query4 = "Crater_Measurement.[A_Depth], Crater_Measurement.[A_Width]," & _
           "Crater_Measurement.[Lip_to_Lip_Diameter], " & _
           "Crater_Measurement.[A_Lip_Ht], " & _
           "Crater_Measurement.[Crater_Side_Slope], " & _
           "Crater_Measurement.[Lip_to_Crater_Depth], " & _
           "Crater_Measurement.[Units], Crater_Measurement.[Volume], " & _
           "Crater_Measurement.[Apparent Surface Area], " & _
           "Crater_Measurement.[Photo North], " & _
           "Crater_Measurement.[Photo South]," & _
           "Crater_Measurement.[Photo East], " & _
           "Crater_Measurement.[Photo West], " & _
           "Crater_Measurement.[Profile (0 or 180)], " & _
           "Crater_Measurement.[Profile (45 or 225)], " & _
           "Crater_Measurement.[Profile (90 or 270)], " & _
           "Crater_Measurement.[Profile (135 or 315)], " & _
           "Crater_Measurement.[Point Cloud]"

  query5 = "Cover.[Cover Type], Cover.[Mass_Units], Cover.[Dist_Units], " & _
           "Cover.[Vehicle], Cover.[Vehicle_Dist_From_Surface], " & _
           "Cover.[Vehicle_Mass], Cover.[Vehicle_L], Cover.[Vehicle_W], " & _
           "Cover.[Vehicle_H], Cover.[Cover_Shape], Cover.[Cover_L]," & _
           "Cover.[Cover_W], Cover.[Cover_T], Cover.[Radius], " & _
           "Cover.[Cover_Mass], Cover.[x], Cover.[y], Cover.[z], " & _
           "Cover.[Dist_From_Surface]"

  query6 = "Charge_Position.[Depth_of_Burst], " & _
           "Charge_Position.[Depth_of_Burial], " & _
           "Charge_Position.[Charge Orientation]"

  queryHead = "SELECT "
  queryTail = " FROM Reference, Soil_Properties, Charge_Type, " & _
              "      Crater_Measurement, Cover, Charge_Position " & _
              " WHERE Reference.Record_Num = " & Me.Text17 & _
              "      And Soil_Properties.Record_Num =" & Me.Text17 & _
              "      And Charge_Type.Record_Num =" & Me.Text17 & _
              "      And Crater_Measurement.Record_Num =" & Me.Text17 & _
              "      And Cover.Record_Num =" & Me.Text17 & _
              "      And Charge_Position.Record_Num =" & Me.Text17

  finalQuery = queryHead
  finalQuery = finalQuery & query1
  finalQuery = finalQuery & ", " & query2
  finalQuery = finalQuery & ", " & query3
  finalQuery = finalQuery & ", " & query4
  finalQuery = finalQuery & ", " & query5
  finalQuery = finalQuery & ", " & query6
  finalQuery = finalQuery & queryTail

  dbLib.QueryDefs.Delete "copyQuery"
  Set qdfNew = dbLib.CreateQueryDef("copyQuery", finalQuery)
End Sub

1 个答案:

答案 0 :(得分:1)

尝试以下方法:

=DLookUp("[Soil Condition]","copyQuery","soil_cond ='" & [Soil Condition] & "'")