shieldsco
asked on
Drill Down on a Form
I using the code below to drill down from one form to another. It works if the match is one word however when the lookup is more than one word it does not find the value. For example if the lookup is "ISSO" the value is found...If the lookup is "System Owner" the value is not found. Any thoughts.
Dim strList As String
strList = "('" & Replace(Me.Currently_With, " ", "','") & "')"
If DCount("*", "UFMS Weakness Remediation Summary", "[Currently With] In " & strList) = 0 Then
MsgBox "No related record found", vbExclamation, "UFMS"
Exit Sub
Else
End If
DoCmd.OpenForm "frm_Remediation Summary", , , "[Currently With] In " & strList
Dim strList As String
strList = "('" & Replace(Me.Currently_With,
If DCount("*", "UFMS Weakness Remediation Summary", "[Currently With] In " & strList) = 0 Then
MsgBox "No related record found", vbExclamation, "UFMS"
Exit Sub
Else
End If
DoCmd.OpenForm "frm_Remediation Summary", , , "[Currently With] In " & strList
ASKER
OFSP
O&M
System Owner
OpDiv
OCIO
O&M
System Owner
OpDiv
OCIO
ASKER
I would prefer not to hard code the values
why are you using this line in your code
strList = "('" & Replace(Me.Currently_With, " ", "','") & "')"
is the control Me.Currently_With, list multiple items?
what is the control Source of the cotrol Me.Currently_With?
strList = "('" & Replace(Me.Currently_With,
is the control Me.Currently_With, list multiple items?
what is the control Source of the cotrol Me.Currently_With?
ASKER
Me.Currently_With is multiple items
and the control source is a query
and the control source is a query
post the query here.
ASKER
SELECT [UFMS Weakness Remediation Summary].[Weakness Remediation Status] AS Status, [UFMS Weakness Remediation Summary].[Currently With], Count([UFMS Weakness Remediation Summary].ID) AS [Number]
FROM [UFMS Weakness Remediation Summary]
GROUP BY [UFMS Weakness Remediation Summary].[Weakness Remediation Status], [UFMS Weakness Remediation Summary].[Currently With];
FROM [UFMS Weakness Remediation Summary]
GROUP BY [UFMS Weakness Remediation Summary].[Weakness Remediation Status], [UFMS Weakness Remediation Summary].[Currently With];
ASKER
Can the spaced be trimed in the query?
<Can the spaced be trimed in the query? > YES, but i don't think it resolve your problem.
how are data entered in the field [Currently With] ?
how are data entered in the field [Currently With] ?
Me.Currently_With is multiple itemsWhen you build this string, why not build it correctly with commas and quotes rather than using spaces that you later have to replace with commas?
Usually when building an IN() string people concatenate the value with the delimiters and then remove the final comma.
strIN = strIN & """" & Me.someitem & ""","
then at the end,
If strIN & "" <> "" Then
strin = Left(StrIN, Len(StrIN) -1)
End If
ASKER
it a list box
ASKER
Dim strList As String
'strList = "('" & Replace(Me.Currently_With, " ", "','") & "')"
StrIN = StrIN & """" & Me.Currently_With & ""","
Pat - No related record found
'If DCount("*", "UFMS Weakness Remediation Summary", "[Currently With] In " & strList) = 0 Then
If StrIN & "" <> "" Then
StrIN = Left(StrIN, Len(StrIN) - 1)
MsgBox "No related record found", vbExclamation, "UFMS"
Exit Sub
Else
End If
DoCmd.OpenForm "frm_Remediation Summary", , , "[Currently With] In " & strList
'strList = "('" & Replace(Me.Currently_With,
StrIN = StrIN & """" & Me.Currently_With & ""","
Pat - No related record found
'If DCount("*", "UFMS Weakness Remediation Summary", "[Currently With] In " & strList) = 0 Then
If StrIN & "" <> "" Then
StrIN = Left(StrIN, Len(StrIN) - 1)
MsgBox "No related record found", vbExclamation, "UFMS"
Exit Sub
Else
End If
DoCmd.OpenForm "frm_Remediation Summary", , , "[Currently With] In " & strList
ASKER
Pat - No related record found
Dim strList As String
'strList = "('" & Replace(Me.Currently_With, " ", "','") & "')"
StrIN = StrIN & """" & Me.Currently_With & ""","
'If DCount("*", "UFMS Weakness Remediation Summary", "[Currently With] In " & strList) = 0 Then
If StrIN & "" <> "" Then
StrIN = Left(StrIN, Len(StrIN) - 1)
MsgBox "No related record found", vbExclamation, "UFMS"
Exit Sub
Else
End If
DoCmd.OpenForm "frm_Remediation Summary", , , "[Currently With] In " & strList
Dim strList As String
'strList = "('" & Replace(Me.Currently_With,
StrIN = StrIN & """" & Me.Currently_With & ""","
'If DCount("*", "UFMS Weakness Remediation Summary", "[Currently With] In " & strList) = 0 Then
If StrIN & "" <> "" Then
StrIN = Left(StrIN, Len(StrIN) - 1)
MsgBox "No related record found", vbExclamation, "UFMS"
Exit Sub
Else
End If
DoCmd.OpenForm "frm_Remediation Summary", , , "[Currently With] In " & strList
I'm confused. Are you building a string of values or are you selecting a single value? If you are selecting a single value then
DoCmd.OpenForm "frm_Remediation Summary", , , "[Currently With] = '" & Me.Currently_With & "'"
is the simplest syntax.
You would only use IN() if you were actually building something that looked like:
'apple', 'orange', 'pear'
DoCmd.OpenForm "frm_Remediation Summary", , , "[Currently With] = 'orange'"
OR
DoCmd.OpenForm "frm_Remediation Summary", , , "[Currently With] In('apple', 'orange', 'pear')"
DoCmd.OpenForm "frm_Remediation Summary", , , "[Currently With] = '" & Me.Currently_With & "'"
is the simplest syntax.
You would only use IN() if you were actually building something that looked like:
'apple', 'orange', 'pear'
DoCmd.OpenForm "frm_Remediation Summary", , , "[Currently With] = 'orange'"
OR
DoCmd.OpenForm "frm_Remediation Summary", , , "[Currently With] In('apple', 'orange', 'pear')"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Rey - Compile error - method or data member not found
.ItemsSelected.Count
.ItemsSelected.Count
what is the name of the listbox, check if it has underscore or no
ASKER
Currently With... no underscore
change this line
With Me.[Currently_With]
with
With Me.[Currently With]
With Me.[Currently_With]
with
With Me.[Currently With]
ASKER
Change to Currently With and received the following error:
method or data member not found
.ItemsSelected.Count
method or data member not found
.ItemsSelected.Count
<.If the lookup is "System Owner" the value is not found>
in your replace statement, the space " " is being replaced, so "System Owner" becomes "SystemOwner"