Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help! my multiSelect List Box isn't functioning

Status
Not open for further replies.

jlitondo

MIS
Jun 27, 2000
175
US
&nbsp;&nbsp;&nbsp;Hi! I have been programming in Access2000 for about a month now and I'm stuck.<br>&nbsp;&nbsp;I have a form called ContractQuotes which has a table called Contracts as its record source.On this same form, I have a list box called CustList and it has a table called Customers as its record source.I set it up as a list box which I thought would be a dandy feature for the end users but I can't get it to work.<br>&nbsp;&nbsp;I wrote a procedure in the click event() of a button to send this selection to a table called CustQuotes. What it does intsead is get to the very first selected record and then generate an error message during runtime that reads &quot;3265 - Item not found in this collection&quot;.I can see that it captures column(0) of the first selection but hangs up there.<br>&nbsp;&nbsp;Could anyone guide me towards my mistake in the following procedure.Thanks in advance.<br><br>Private sub CmdAddCustomers_Click()<br>&nbsp;&nbsp;&nbsp;&nbsp;Call GetSelectedRows()<br>End Sub<br><br>Private Sub GetSelectedRows()<br><br>&nbsp;&nbsp;&nbsp;&nbsp;Dim varList As Control, varCount AsVariant<br>&nbsp;&nbsp;&nbsp;&nbsp;Dim QuoteTableVar As Recordset<br><br>&nbsp;&nbsp;&nbsp;&nbsp;' Set List Control Variable<br>&nbsp;&nbsp;&nbsp;&nbsp;Set varList = Forms![ContractQuotes]!CustList<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;'Open Receiving table<br>&nbsp;&nbsp;&nbsp;&nbsp;Set QuoteTableVar = CurrentDb.OpenRecordset(&quot;CustQuotes&quot;, dbOpenDynaset)<br><br>&nbsp;&nbsp;&nbsp;&nbsp;' Loop through selected items.<br>&nbsp;&nbsp;&nbsp;&nbsp;For Each varCount In varList.ItemsSelected<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;QuoteTableVar.AddNew<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;'''the following line provides me with the error msg'''<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;QuoteTableVar!QuoteTable! = varList.ItemData (varCount)<br>&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;QuoteTableVar.Update<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;Next varCount<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;QuoteTableVar.Close<br><br>End Sub<br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top