2012-03-22 23 views
0

質問表copyQueryにはSoil Conditionのいずれかの列がありますが、別の形式のコンボボックスsoil_condをデフォルト値Soil ConditionからcopyQueryにする必要があります。コンボボックスのデフォルト値

コンボボックスsoil_condには、クエリではない3つの値があります。

私はこれを試して、コンボボックス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 
+0

ためのSQLを投稿してくださいcopyQueryと行sourcあなたのコンボのためのe。 – Fionnuala

+0

私の質問が更新されましたが、何らかの理由でこれが1つのテキストボックスフォーム= DLookUp( "[Test Name]"、 "copyQuery")のデフォルト値として機能しますが、別のフォームの別のテキストボックスでは機能しません。唯一の違いは、他のフォームは、データ入力のためのnoを持っています – nman84

+0

私は戻って、デフォルト値の仕事をする方法があることを取る:私もこのプライベートSub Form_Current()を試しました Me.soil_cond.DefaultValue = DLookup( "[土壌条件]" 、 "copyQuery") End Sub – nman84

答えて

1

は、以下のことを試してみてください。

=DLookUp("[Soil Condition]","copyQuery","soil_cond ='" & [Soil Condition] & "'") 
関連する問題