New topic: 

ListBox Return Value

<http://forums.realsoftware.com/viewtopic.php?t=38946>

         Page 1 of 1
   [ 4 posts ]                 Previous topic | Next topic          Author  
Message        rjohnsonvtp          Post subject: ListBox Return ValuePosted: 
Sun May 08, 2011 7:05 pm                         
Joined: Tue Nov 18, 2008 9:19 pm
Posts: 3                I'm new to RB but have been developing a long time. 
Seems I am not good enough to figure this out.

I'm able to populate a listbox (ListBox1 in this case) with a SQL Query that 
has three columns.  
 userID (int)
 DisplayName (String)
 LastName (String)

I need the userID for a subsequent data query recordset, but am showing 
successfully the DisplayName. I use the LastName to do the sort.

The problem is that when the user selects the desired row, I can't get the 
desired (or any) result from the ListBox1.ListIndex to use in the recordset 
query. I can hardcode the userID in the SQL and it works fine. 

I grovel for any help.
Real Studio 2011 Release 1.1

Here's the select code:

..
               "b.street, " + _       '35
               "b.run_ingestion_tool " + _ '36
            "from dss.users a, " + _
               "dss.users_properties b " + _
            "where  a.duid = b.duid " + _
                "and a.duid = $1 "))
 
  Dim userDuid as  integer = me.Cell(me.ListIndex, 0)
  
  Dim rs As RecordSet = stmt.SQLSelect(userDuid)  

 //Load the users data into the form  
  txtFirstName.text = rs.idxField(17).stringValue
  txtLastName.text = rs.idxField(18).stringValue
..   
                             Top                 markwalsh          Post 
subject: Re: ListBox Return ValuePosted: Sun May 08, 2011 8:34 pm               
          
Joined: Wed May 20, 2009 4:43 pm
Posts: 502                Store the ID in the rowTag for each row      
_________________
RB 2009r4 Windows XP  
                             Top                 rjohnsonvtp          Post 
subject: Re: ListBox Return ValuePosted: Sun May 08, 2011 10:05 pm              
           
Joined: Tue Nov 18, 2008 9:19 pm
Posts: 3                Mark,

Thanks for the quick reply.

Here's the method I tried to modify that loads the listbox in question. Maybe 
I'm not loading it right in the first place, before I added the rowtag. I'm 
getting an outofbounds exception on loading the selection from the listbox.

------
  Dim i As Integer
  Dim rs as RecordSet 
  rs = app.db.sqlselect("select duid, display_name from dss.users_properties 
order by last_name asc")
  
  Listbox1.DeleteAllRows
  
  Do Until rs.EOF
  Listbox1.AddRow rs.IdxField(2).StringValue //display second column from the 
select
  ListBox1.RowTag(ListBox1.LastIndex) = rs.Field("_rowid").Int64Value
  rs.MoveNext
  Loop
------   
                             Top                 imagoworld          Post 
subject: Re: ListBox Return ValuePosted: Mon May 09, 2011 12:25 am              
           
Joined: Mon Jan 04, 2010 3:43 pm
Posts: 30                Hi,

Is rs.Field("_rowid").Int64Value for the field duid ? I would use :

ListBox1.RowTag(ListBox1.LastIndex) = rs.IdxField(1).StringValue

or enter the field _rowid in your sql query :

select _rowid, duid, display_name from dss.users_properties order by last_name 
asc

cheers,

Sam   
                             Top            Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 4 posts ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

rbforumnotifier@monkeybreadsoftware.de

Reply via email to