Can't get Master-Detail to work

In this forum we will discuss things relating the ZEOSLib 6.6.x stable versions

Moderators: gto, EgonHugeist

Post Reply
MrBaseball34
Fresh Boarder
Fresh Boarder
Posts: 3
Joined: 03.12.2010, 22:15

Can't get Master-Detail to work

Post by MrBaseball34 »

I have two detail queries and one master query.
Master is :

Code: Select all

object qryInventory: TZQuery
  Connection = dbConnection
  AfterScroll = qryInventoryAfterScroll
  SQL.Strings = (
    'SELECT i.inventory_id, '
    '       i.inventory_part_number,'
    '       i.inventory_alt_part_number,'
    '       i.inventory_condition,'
    '       i.inventory_quantity,'
    '       i.inventory_desc,'
    '       i.inventory_comments,'
    '       i.inventory_last_update,'
    '       i.inventory_location'
    'FROM inventory i'
    'WHERE active'
    'ORDER BY inventory_id')
  Params = <>
  Left = 101
  Top = 69
  object qryInventoryinventory_id: TIntegerField
    FieldName = 'inventory_id'
    Required = True
  end
  object qryInventoryinventory_part_number: TStringField
    FieldName = 'inventory_part_number'
    Required = True
    Size = 50
  end
  object qryInventoryinventory_alt_part_number: TStringField
    FieldName = 'inventory_alt_part_number'
    Size = 50
  end
  object qryInventoryinventory_condition: TStringField
    FieldName = 'inventory_condition'
    Required = True
    Size = 2
  end
  object qryInventoryinventory_quantity: TIntegerField
    FieldName = 'inventory_quantity'
    Required = True
  end
  object qryInventoryinventory_desc: TStringField
    FieldName = 'inventory_desc'
    Required = True
    Size = 100
  end
  object qryInventoryinventory_comments: TMemoField
    FieldName = 'inventory_comments'
    BlobType = ftMemo
  end
  object qryInventoryinventory_last_update: TDateTimeField
    FieldName = 'inventory_last_update'
  end
  object qryInventoryinventory_location: TMemoField
    FieldName = 'inventory_location'
    OnGetText = qryInventoryinventory_locationGetText
    BlobType = ftMemo
  end
end
Two detail queries are like this:

Code: Select all

object qryQuotes: TZQuery
  Connection = dbConnection
  SQL.Strings = (
    'SELECT * FROM quote_history'
    'WHERE active'
    '  AND inventory_id = :inventory_id'
    'ORDER BY inserted DESC')
  Params = <
    item
      DataType = ftUnknown
      Name = 'inventory_id'
      ParamType = ptUnknown
    end>
  MasterFields = 'inventory_id'
  MasterSource = dsInventory
  Left = 170
  Top = 69
  ParamData = <
    item
      DataType = ftUnknown
      Name = 'inventory_id'
      ParamType = ptUnknown
    end>
  object qryQuotesquote_id: TIntegerField
    FieldName = 'quote_id'
    Required = True
  end
  object qryQuotesinventory_id: TIntegerField
    FieldName = 'inventory_id'
  end
  object qryQuotesprice: TFloatField
    DisplayLabel = 'Quoted Price'
    FieldName = 'price'
    DisplayFormat = '$ #.00'
    currency = True
  end
  object qryQuotesinserted: TDateTimeField
    DisplayLabel = 'Date'
    FieldName = 'inserted'
    ReadOnly = True
    DisplayFormat = 'dd/mm/yyyy'
  end
  object qryQuotesComments: TMemoField
    DisplayLabel = 'Comments'
    FieldName = 'comments'
    OnGetText = qryQuotesCommentsGetText
    BlobType = ftMemo
  end
end

Code: Select all

object qrySales: TZQuery
  Connection = dbConnection
  SQL.Strings = (
    'SELECT * FROM sales_history'
    'WHERE active'
    '  AND inventory_id = :inventory_id'
    'ORDER BY inserted DESC')
  Params = <
    item
      DataType = ftUnknown
      Name = 'inventory_id'
      ParamType = ptUnknown
    end>
  MasterFields = 'inventory_id'
  MasterSource = dsInventory
  Left = 315
  Top = 71
  ParamData = <
    item
      DataType = ftUnknown
      Name = 'inventory_id'
      ParamType = ptUnknown
    end>
  object qrySalessold_id: TIntegerField
    FieldName = 'sold_id'
    Required = True
  end
  object IntegerField2: TIntegerField
    FieldName = 'inventory_id'
  end
  object FloatField1: TFloatField
    DisplayLabel = 'Quoted Price'
    FieldName = 'price'
    DisplayFormat = '$ #.00'
    currency = True
  end
  object DateTimeField1: TDateTimeField
    DisplayLabel = 'Date'
    FieldName = 'inserted'
    ReadOnly = True
    DisplayFormat = 'dd/mm/yyyy'
  end
  object MemoField1: TMemoField
    DisplayLabel = 'Comments'
    FieldName = 'comments'
    OnGetText = qryQuotesCommentsGetText
    BlobType = ftMemo
  end
end
Now. I do not see any detail records even though I am certain there are records in the detail tables that match the criteria.

Am I doing something wrong here?
trupka
Expert Boarder
Expert Boarder
Posts: 140
Joined: 26.08.2007, 22:10

Post by trupka »

Try this:
clear MasterFields and MasterSource properties
set
DetailQuery.Datasource := MasterQuery.DataSource

Check that DetailQuery param names are the same as corresponding master fields.
MrBaseball34
Fresh Boarder
Fresh Boarder
Posts: 3
Joined: 03.12.2010, 22:15

Post by MrBaseball34 »

What a life saver. thanks a million. I actually forgot about that.
Post Reply