G
Guest
I want to use a query to load a control. I have minimal SQL and VBA know
how. This is what I am trying to do:
I am starting off in Form![Chart]. Using AfterUpdate in Form![Chart].[24D1
CPT] I need to do a query: I want to select from Table![Insurance Company]
where Table![Insurance Company] .ID is equal to the value in the
Form![Chart]. [InsuranceCompany] then select the field in
Table![Chart].[Insurance Company] who’s name is equal to the value in
Form!Chart.[24D1 CPT]. I want to use the results of this query to fill
Form!Chart.[ 24F1 Charges]. Code Follows:
Private Sub Ctl24D1_CPT_AfterUpdate()
Dim SQL As String
SQL = "SELECT [Insurance Companies].ID, [Insurance Companies]." & _
Me![24D1 CPT] & "FROM [Insurance Companies]" & _
"WHERE ((([Insurance
Companies].ID)=[Forms]![Chart].[InsuranceCompany]));"
DoCmd.RunSQL SQL
End Sub
I have gotten this far and do not know if I am on the right track or what to
do next. I know that the program stops at DoCmd.RunSQL SQL so something is
not right and I am not sure how to get my results into the control after the
query is done.
how. This is what I am trying to do:
I am starting off in Form![Chart]. Using AfterUpdate in Form![Chart].[24D1
CPT] I need to do a query: I want to select from Table![Insurance Company]
where Table![Insurance Company] .ID is equal to the value in the
Form![Chart]. [InsuranceCompany] then select the field in
Table![Chart].[Insurance Company] who’s name is equal to the value in
Form!Chart.[24D1 CPT]. I want to use the results of this query to fill
Form!Chart.[ 24F1 Charges]. Code Follows:
Private Sub Ctl24D1_CPT_AfterUpdate()
Dim SQL As String
SQL = "SELECT [Insurance Companies].ID, [Insurance Companies]." & _
Me![24D1 CPT] & "FROM [Insurance Companies]" & _
"WHERE ((([Insurance
Companies].ID)=[Forms]![Chart].[InsuranceCompany]));"
DoCmd.RunSQL SQL
End Sub
I have gotten this far and do not know if I am on the right track or what to
do next. I know that the program stops at DoCmd.RunSQL SQL so something is
not right and I am not sure how to get my results into the control after the
query is done.