Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
FYI; Problem with PADL; .NULL. in SELECT SQL
Message
From
24/06/2009 08:27:09
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
24/06/2009 08:18:58
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01407500
Message ID:
01407987
Views:
28
This seems to work:
Public oForm
oForm = Createobject('comboSample')
oForm.Show

Define Class comboSample As Form
  Top = 0
  Left = 0
  Height = 350
  Width = 620
  DataSession=2

  Add Object grdItems As Grid With ;
    Height = 300, ;
    Left = 10, ;
    Top = 10, ;
    Width = 600, ;
    Rowheight = 19,;
    RecordSource = "crsItems"

  Procedure Load
    Set Fixed On
    Set Point To ","

    Select Cast(.Null. As Int) As ProductID, Cast('' As c(50)) As prod_name ;
      FROM (_samples+'Data\products') ;
      UNION ;
      select Int(Val(product_id)) As ProductID,prod_name ;
      FROM (_samples+'Data\products') ;
      INTO Cursor crsProducts ;
      readwrite
    Index On ProductID Tag ProductID

    Create Cursor crsItems ;
      (LINE_NO i, ORDER_ID c(6), ;
      ProductID i Null, UNIT_PRICE Y, QUANTITY i)

    Insert Into crsItems ;
      Select LINE_NO, ORDER_ID, ;
      Val(product_id) As ProductID, ;
      UNIT_PRICE, QUANTITY ;
      From (_samples+'data\orditems')
    Locate

    Use In 'products'
    Use In 'orditems'

  Endproc

  Procedure grdItems.Init
    Local ix
    With This
      For ix = 1 To .ColumnCount
        If Upper(Justext(.Columns(m.ix).ControlSource)) == 'PRODUCTID'
          With .Columns(m.ix)
            .Bound = .F.
            .ControlSource = "(Iif(Seek(crsItems.productid,"+;
              "'crsProducts','productID'),crsProducts.prod_name,''))"
            .Width = 180
            .Alignment = 0
            .AddObject('comboincol','mycombo')
            With .ComboIncol
              .BoundColumn = 2
              .BoundTo = .T.
              .ColumnCount = 2
              .ColumnWidths = "180,100"
              .RowSourceType = 3
              .RowSource = "select prod_name,productID"+;
                " from crsProducts"+;
                " order by 1" +;
                " into cursor crsComboSource"
              .SpecialEffect = 1
              .Style = 2
              .ControlSource = "crsItems.productID"
              .Visible = .T.
            Endwith
            .CurrentControl = 'comboincol'
          Endwith
          Exit
        Endif
      Endfor
      .AddColumn(.ColumnCount+1)
      .Columns(.ColumnCount).Name = 'showProdID'
      .ShowProdID.ControlSource = '(crsItems.ProductID)'
    Endwith
  Endproc

Enddefine

Define Class myCombo As ComboBox
  setFixed = ''
  Procedure init
    This.setFixed = Set('fixed')
  endproc
  Procedure when
    Set Fixed Off
  Endproc

  Procedure LostFocus
    Local cfixed
    cfixed = This.setFixed
    Set Fixed &cfixed
  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