A
Ally
I have a form (form#1) with a list box displayed on the top of the page. The
list box includes a list of capital items with project# (colum 1), cost
center Number (colum2), description (colum3), estimated cost (column 4) and
fiscal year (column 5) displayed on the top of the form. The form one also
has a several command buttions listed on the bottom of the page such as Edit,
Search, New, etc. It works fine itself with all command buttons funtioning
correct. The column 1 = project# is the boundcolumn used to display further
detailed information about each capital item once Edit button is selected.
However, I have a need for adding another form (form#2) before I come to the
form one as I only want to deal with the list of one fiscal year, so the
form#2 has a list box that can select the fiscal year (boundcolumn is 1 which
is the field FiscalYear) and by select "Edit" buttion on form#2 should bring
up the form#1 for capital items for only the selected fiscal year.
It sounds easy... but it did not work right for me so far as no matter which
year I selected in form#2, the form#1 still displays all capital items for
every fiscal year.
Here is the code for form#2:
If Me!FiscalYear.ItemsSelected.Count > 0 Then
For Each varItem In Me!FiscalYear.ItemsSelected
str = str & Chr$(34) & Me!FiscalYear.Column(0, varItem) &
Chr$(34) & ","
Next varItem
str = Left$(str, Len(str) - 1)
If IsNothing(strWhere) Then
strWhere = "[FiscalYear] IN (" & str & ")"
Dim MyVar
MyVar = strWhere
Debug.Print MyVar
Else
strWhere = strWhere & " AND [FiscalYear] IN (" & str & ")"
End If
End If
DoCmd.OpenForm FormName:="frmApprOver50KSelect", WhereCondition:=strWhere
DoCmd.Close acForm, Me.Name
Would you please let me know why it happens this way? really appreciate it!!!
Thanks in advance!
Ally
list box includes a list of capital items with project# (colum 1), cost
center Number (colum2), description (colum3), estimated cost (column 4) and
fiscal year (column 5) displayed on the top of the form. The form one also
has a several command buttions listed on the bottom of the page such as Edit,
Search, New, etc. It works fine itself with all command buttons funtioning
correct. The column 1 = project# is the boundcolumn used to display further
detailed information about each capital item once Edit button is selected.
However, I have a need for adding another form (form#2) before I come to the
form one as I only want to deal with the list of one fiscal year, so the
form#2 has a list box that can select the fiscal year (boundcolumn is 1 which
is the field FiscalYear) and by select "Edit" buttion on form#2 should bring
up the form#1 for capital items for only the selected fiscal year.
It sounds easy... but it did not work right for me so far as no matter which
year I selected in form#2, the form#1 still displays all capital items for
every fiscal year.
Here is the code for form#2:
If Me!FiscalYear.ItemsSelected.Count > 0 Then
For Each varItem In Me!FiscalYear.ItemsSelected
str = str & Chr$(34) & Me!FiscalYear.Column(0, varItem) &
Chr$(34) & ","
Next varItem
str = Left$(str, Len(str) - 1)
If IsNothing(strWhere) Then
strWhere = "[FiscalYear] IN (" & str & ")"
Dim MyVar
MyVar = strWhere
Debug.Print MyVar
Else
strWhere = strWhere & " AND [FiscalYear] IN (" & str & ")"
End If
End If
DoCmd.OpenForm FormName:="frmApprOver50KSelect", WhereCondition:=strWhere
DoCmd.Close acForm, Me.Name
Would you please let me know why it happens this way? really appreciate it!!!
Thanks in advance!
Ally