Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Combo box to scroll thru a database
Message
From
23/03/2010 08:28:10
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
22/03/2010 11:24:44
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01456119
Message ID:
01456428
Views:
64
This message has been marked as a message which has helped to the initial question of the thread.
>>>>>hello!
>>>>>i knwo the code to scrool thru a table like
>>>>>
>>>>>if not eof()
>>>>>skip 1
>>>>>etc etc
>>>>>
>>>>>but im trying to use a combo box
>>>>>lets say i hav a CB with 2 values A and B. A is 5 and B is 20
>>>>>when i load the form A shows me a value of 5...in a text box but when i select B 20 doesnt show. :(
>>>>>should i change to...a scroll bar?but i wanted to be able to see the choces
>>>>
>>>>I think you need to re-state your problem in a way others can understand. May be you need to go to the record with that primary key, e.g.
>>>>
>>>>lnPK = thisform.myCombo.value
>>>>if seek(lnPK, 'myTable', 'myPKTag')
>>>>   thisform.refresh()
>>>>endif
>>>>
>>>
>>>oh
>>>uhum
>>>if i use a scroll bar i know how to move thru my table granted it has two fields and 4 values like
>>>table
>>>
>>>A   5
>>>B   10
>>>
>>>but im trying to use a combo box so when i select A my fields get 5 and B gives me 10
>>>when i init the form the field gets 5 but i dont get 10 upon the selection of B
>>
>>Re-read my reply one more time and also post how did you setup your comobox (what is its rowsourcetype and rowsource).
>
>my row source is an sql
>select fields from table where intemtype="x" into cursor test
>3-SQL satement


(Assuming your table's name is myTable, primary key field name is pkField and index tag name is myPkTag)
select fieldA,fieldB, ..., pkField from myTable where intemtype="x" into cursor test
InteractiveChange or Valid:
=seek(test.pkField, 'myTable', 'myPkTag')
thisform.refresh()
Do not use combo.value or such. Directly use test.fieldname. Here is a complete sample using testdata!customer:
Public oForm
oForm = Createobject('comboSample')
oForm.Show

Define Class comboSample As Form
  DataSession = 2
  Add Object t1 As TextBox With ;
    top=10,Left=10,ControlSource='customer.cust_id'
  Add Object t2 As TextBox With ;
    top=40,Left=10,ControlSource='customer.Company'
  Add Object t3 As TextBox With ;
    top=70,Left=10,ControlSource='customer.Contact'

  Add Object cmbSample As ComboBox With ;
    top=100,Left=10,Width=200,;
    Style = 2, ;
    RowSourceType=3,;
    RowSource='select Company, cust_id'+;
    ' from (_samples+"data\customer")'+;
    ' into cursor crsCustomers'

  Procedure Load
    Set Multilocks On
    Use (_samples+'data\Customer')
    CursorSetProp("Buffering",5,'Customer') && don't want to really save during testing
  Endproc

  Procedure cmbSample.InteractiveChange
    =Seek(crsCustomers.Cust_id,'customer','cust_id')
    This.Parent.Refresh()
  Endproc
Enddefine
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform