S
Steve Taber
I've set up a database that uses a search box to look up reports. I borrowed
some code from a training book, but it isn't working right. The information
fields within the search box are populated. When I hit the search button it
does open the form I want, but it doesn't contain any information., Here is
the code:
Private Sub Command5_Click()
Dim strWhere As String, varItem As Variant
' Request to edit items selected in the list box
' If no items selected, then nothing to do
If Me!List14.ItemsSelected.Count = 0 Then Exit Sub
' Loop through the items selected collection
For Each varItem In Me!List14.ItemsSelected
' Grab the CompanyID column for each selected item
strWhere = strWhere & Me!List14.Column(0, varItem) & ","
Next varItem
' Throw away the extra comma on the "IN" string
strWhere = Left$(strWhere, Len(strWhere) - 1)
' Open the companies form filtered on the selected companies
strWhere = "[Date] IN (" & strWhere & ")"
DoCmd.OpenForm FormName:="Incident Report", WhereCondition:=strWhere
DoCmd.Close acForm, Me.Name
End Sub
[Date] is the field I am using as a reference from my query. Incident Report
is the form name.
I have almost no idea what I am doing with VBA. Anyone have any ideas?
Thanks,
Steve
some code from a training book, but it isn't working right. The information
fields within the search box are populated. When I hit the search button it
does open the form I want, but it doesn't contain any information., Here is
the code:
Private Sub Command5_Click()
Dim strWhere As String, varItem As Variant
' Request to edit items selected in the list box
' If no items selected, then nothing to do
If Me!List14.ItemsSelected.Count = 0 Then Exit Sub
' Loop through the items selected collection
For Each varItem In Me!List14.ItemsSelected
' Grab the CompanyID column for each selected item
strWhere = strWhere & Me!List14.Column(0, varItem) & ","
Next varItem
' Throw away the extra comma on the "IN" string
strWhere = Left$(strWhere, Len(strWhere) - 1)
' Open the companies form filtered on the selected companies
strWhere = "[Date] IN (" & strWhere & ")"
DoCmd.OpenForm FormName:="Incident Report", WhereCondition:=strWhere
DoCmd.Close acForm, Me.Name
End Sub
[Date] is the field I am using as a reference from my query. Incident Report
is the form name.
I have almost no idea what I am doing with VBA. Anyone have any ideas?
Thanks,
Steve