G
Guest
I have a form with one listbox on it. This form is populated from a table
that contains one field. The user can pick one or more company IDs from
that table, hit continue, and then data is pulled from another table based on
that company ID, and transferred to an Excel spreadsheet.
My problem is after running this, for some reason the first record in the
table is replaced with a blank. And so the listbox shows up with a blank at
the top, since it's pulling from the table.
I even tried to work around this by having the table with company IDs
repopulated each time from the master table. That's fine, unless the user
runs this once and then decides to run it again without starting over and
repopulating the table, because once run, the first record is replaced by an
empty string or null or something.
My code is as follows -- this is the only code that touches the listbox.
Everything else seems to work. thanks in advance
For intCounter = 0 To (lstOrgNames.ItemsSelected.Count - 1)
intSelectedIndex = lstOrgNames.ItemsSelected.Item(intCounter)
strCompanyName = lstOrgNames.ItemData(intSelectedIndex)
strCompanyTableName = "temp_tbl" & strCompanyName
strSQL = "SELECT Orgname,Account, Total, Classification INTO " &
strCompanyTableName & _
" FROM " & gstrSourceTableName & " WHERE orgname =
'" & strCompanyName & "'"
cnn.Execute strSQL
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9,
strCompanyTableName, CurrentProject.Path & "\" & strCompanyTableName, True
Next intCounter
that contains one field. The user can pick one or more company IDs from
that table, hit continue, and then data is pulled from another table based on
that company ID, and transferred to an Excel spreadsheet.
My problem is after running this, for some reason the first record in the
table is replaced with a blank. And so the listbox shows up with a blank at
the top, since it's pulling from the table.
I even tried to work around this by having the table with company IDs
repopulated each time from the master table. That's fine, unless the user
runs this once and then decides to run it again without starting over and
repopulating the table, because once run, the first record is replaced by an
empty string or null or something.
My code is as follows -- this is the only code that touches the listbox.
Everything else seems to work. thanks in advance
For intCounter = 0 To (lstOrgNames.ItemsSelected.Count - 1)
intSelectedIndex = lstOrgNames.ItemsSelected.Item(intCounter)
strCompanyName = lstOrgNames.ItemData(intSelectedIndex)
strCompanyTableName = "temp_tbl" & strCompanyName
strSQL = "SELECT Orgname,Account, Total, Classification INTO " &
strCompanyTableName & _
" FROM " & gstrSourceTableName & " WHERE orgname =
'" & strCompanyName & "'"
cnn.Execute strSQL
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9,
strCompanyTableName, CurrentProject.Path & "\" & strCompanyTableName, True
Next intCounter