I have a form (frm_Consolidated) that I would like to drill down to another form(frm_details) based on the following four frm_Consolidated fields:
1. Source
2. Contributes to IT MW
3. OpDivs… this is a concatenated field : OpDiv+Year_Identified
4. Risk Rating
The linked field is “Remaining Open” in the frm_Consolidated.
The related fields in the “frm_details” are
1. Source
2. Contributing_MW
3. OpDiv
4. Year_Identified
5. Risk_Rating
The name of the form to open from the drill down is frm_details.
Can you provide code to perform this routine? A sample DB is attached.
I've tried using the code below but not records are found:
If DCount("*", "tbl_Consolidated_Import", "[Source]='" & Me.Source & "And [Risk Rating]= " & Me.Risk_Rating & "And [Contributes to IT MW]= " & Me.Contributes_to_IT_MW & "'") = 0 Then
MsgBox "No related record found", vbExclamation, "DSPC"
Exit Sub
Else
'open form
DoCmd.OpenForm "frm_details", , , "[Source]='" & Me.Source And [Risk Rating] = " & Me.Risk_Rating & And [Contributes to IT MW] = " & Me.Contributes_to_IT_MW & " '"
If "Source" is a Text field, then you need a closing single quote after that, and you also need to be sure your spacing is correct on all of the AND concats.
You also seem to have a trailing double quote at the end.
If DCount("*", "tbl_Consolidated_Import", "[Source]='" & Me.Source & "' And [Risk Rating]= " & Me.Risk_Rating & " And [Contributes to IT MW]= " & Me.Contributes_to_IT_MW) = 0
Assuming Risk Rating and Contributes to IT MW are numeric or boolean fields, that should work.
If DCount("*", "tbl_Consolidated_Import", "[Source]='" & Me.Source & "' And [Risk Rating]= " & Me.Risk_Rating = "High" Or "Moderate" Or "Low" & " And [Contributes to IT MW]= " & Me.Contributes_to_IT_MW) = 0 Then
DoCmd.OpenForm "frm_details", , , "[Source]='" & Me.Source And [Risk Rating] = " & Me.Risk_Rating & And [Contributes to IT MW] = " & Me.Contributes_to_IT_MW & " '"
If DCount("*", "tbl_Consolidated_Import", "[Source]='" & Me.Source & "' And [Risk Rating]= '" & Me.Risk_Rating & "' And [Contributes to IT MW]= '" & Me.Contributes_to_IT_MW & "'") = 0 Then
MsgBox "No related record found", vbExclamation, "DSPC"
Exit Sub
Else
DoCmd.OpenForm "frm_details", , , "[Source]='" & Me.Source & "' And [Risk_Rating] = '" & Me.Risk_Rating & "' And [Contributes to IT MW] = '" & Me.Contributes_to_IT_MW & "'"
End If
the other problem is you are using names of the field that is not in the table "tbl_Consolidated_Import"
like [Risk Rating] which should be Risk_Rating
and [Contributes to IT MW] which should be [Contributing_MW]
so try using this
If DCount("*", "tbl_Consolidated_Import", "[Source]='" & Me.Source & "' And [Risk_Rating]= '" & Me.Risk_Rating & "' And [Contributing_MW]= '" & Me.Contributes_to_IT_MW & "'") = 0 Then
MsgBox "No related record found", vbExclamation, "DSPC"
Exit Sub
Else
DoCmd.OpenForm "frm_details", , , "[Source]='" & Me.Source & "' And [Risk_Rating] = '" & Me.Risk_Rating & "' And [Contributing_MW] = '" & Me.Contributes_to_IT_MW & "'"
Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.
If "Source" is a Text field, then you need a closing single quote after that, and you also need to be sure your spacing is correct on all of the AND concats.
You also seem to have a trailing double quote at the end.
If DCount("*", "tbl_Consolidated_Import",
Assuming Risk Rating and Contributes to IT MW are numeric or boolean fields, that should work.