MichaelM99
Programmer
Hi -
Two months ago, I returned to VFP after a 25 year absence from any programming other than the occasional website. It has, in the main, been a very pleasant culture shock and I am really glad that, despite Microsoft, the VFP community is still so strong. I am older but sadly not wiser - hence my appearance here.
I am working on a project for a small restaurant a friend is opening here in Nicaragua (I originate from London, England - another culture shock!). It has been a steep relearning curve but my old passion has returned! I am using VFP9 - I can't remember what it was when I last used it but much came back to me very quickly although I made a classic data normalisation mistake for recipes where I have fields for ingredient1, ingredient2 up to ingredient15.
Available ingredients are shown in a style=2 combo - one for each of the (up to) 15 ingredients. This is repeated for ingredient units. That is all working fine but bad design.
I am now working on the drinks side but want to design it properly but I am getting into a real mess with mixed drinks which are basically recipes.
I have 3 tables, one with just 2 fields, Drinks - DrinkID and DrinkName.
Then a table with 3 fields, Items - DrinkID, ItemID and Quantity (there will doubtless be others).
Lastly, I am using the recipes ingredient table with a logical field Drink from which I select the available drink ingredients - it made sense to me to use that table as all stock movements are recorded there so makes reporting easier. The relevant fields are ItemID, ItemName. It also has a UnitID linking to a Units table but that is not really relevant here.
Unlike my earlier mess, I just want to show combos under each other with a line for each item with a button to add a new line for a new item. This I am trying to do with AddObject.
The relevant bits of code are:
First, COUNT FOR DrinkItems.DrinkMadeID = Drinks.DrinkMadeID TO Thisform.ItemLines && get number of items
Then SQL - SELECT ingredie
SELECT Ingredie.Ingred_id, Ingredie.ingredient, Ingredie.drinkshow ;
FROM ;
RECIPES!INGREDIE ;
WHERE Ingredie.drink = .t. ;
ORDER BY Ingredie.ingredient ;
INTO CURSOR curIngred
This is the list I want in each combo obviously displaying the previously chosen one.
Then I am calling a method, AddItemLines as many times as there are ItemLines.
This method has had many different shapes over the past few days but none have worked - the combos are usually greyed out or empty. I have had it working with one iteration of AddItemLines but that is not very useful. This is the current incarnation:
LOCAL lnWorkArea
lnWorkArea = SELECT()
SELECT DrinkItems
n=ALLTRIM(STR(thisform.combonext))
thisform.AddObject('Combo&n','Combobox')
WITH thisform.Combo&n
.BoundColumn = 2
.BoundTo = .t.
.ControlSource = Ingredie.Ingredient && not sure whether quotes are necessary
.DisplayCount = 0
.FirstElement = 1
.RowSource = "curIngred.Ingredient, Ingred_ID"
.RowSourceType = 5
.height = 24
.left = 80
.style = 2
.top = thisform.ctop
.width = 200
.visible = .t.
.enabled = .t.
ENDWITH
thisform.AddObject('ntxtBox&n', 'TextBox')
WITH thisform.ntxtBox&n
.ControlSource = DrinkItems.Quantity
.top = thisform.ctop
.width = 25
.left = 283
.InputMask = "99"
.value = 1
. visible = .t.
ENDWITH
SKIP
thisform.combonext = thisform.ComboNext + 1
thisform.cTtop = thisform.cTop + 27
SELECT(lnWorkArea)
I am sure that there is something fundamentally wrong with my thinking but I am now at the point of despair! I have tried array as I think there is a problem with the Items record pointer have to move with each new row. I just cannot now see the wood from the trees. I know there is some inconsistency between field names but they are consistent in my code.
Any help pointing me in the right direction would be very much appreciated. I have followed this formum for a while and am amazed at the quality of the members, present company excepted! I have already learned so much.
Michael
Two months ago, I returned to VFP after a 25 year absence from any programming other than the occasional website. It has, in the main, been a very pleasant culture shock and I am really glad that, despite Microsoft, the VFP community is still so strong. I am older but sadly not wiser - hence my appearance here.
I am working on a project for a small restaurant a friend is opening here in Nicaragua (I originate from London, England - another culture shock!). It has been a steep relearning curve but my old passion has returned! I am using VFP9 - I can't remember what it was when I last used it but much came back to me very quickly although I made a classic data normalisation mistake for recipes where I have fields for ingredient1, ingredient2 up to ingredient15.
Available ingredients are shown in a style=2 combo - one for each of the (up to) 15 ingredients. This is repeated for ingredient units. That is all working fine but bad design.
I am now working on the drinks side but want to design it properly but I am getting into a real mess with mixed drinks which are basically recipes.
I have 3 tables, one with just 2 fields, Drinks - DrinkID and DrinkName.
Then a table with 3 fields, Items - DrinkID, ItemID and Quantity (there will doubtless be others).
Lastly, I am using the recipes ingredient table with a logical field Drink from which I select the available drink ingredients - it made sense to me to use that table as all stock movements are recorded there so makes reporting easier. The relevant fields are ItemID, ItemName. It also has a UnitID linking to a Units table but that is not really relevant here.
Unlike my earlier mess, I just want to show combos under each other with a line for each item with a button to add a new line for a new item. This I am trying to do with AddObject.
The relevant bits of code are:
First, COUNT FOR DrinkItems.DrinkMadeID = Drinks.DrinkMadeID TO Thisform.ItemLines && get number of items
Then SQL - SELECT ingredie
SELECT Ingredie.Ingred_id, Ingredie.ingredient, Ingredie.drinkshow ;
FROM ;
RECIPES!INGREDIE ;
WHERE Ingredie.drink = .t. ;
ORDER BY Ingredie.ingredient ;
INTO CURSOR curIngred
This is the list I want in each combo obviously displaying the previously chosen one.
Then I am calling a method, AddItemLines as many times as there are ItemLines.
This method has had many different shapes over the past few days but none have worked - the combos are usually greyed out or empty. I have had it working with one iteration of AddItemLines but that is not very useful. This is the current incarnation:
LOCAL lnWorkArea
lnWorkArea = SELECT()
SELECT DrinkItems
n=ALLTRIM(STR(thisform.combonext))
thisform.AddObject('Combo&n','Combobox')
WITH thisform.Combo&n
.BoundColumn = 2
.BoundTo = .t.
.ControlSource = Ingredie.Ingredient && not sure whether quotes are necessary
.DisplayCount = 0
.FirstElement = 1
.RowSource = "curIngred.Ingredient, Ingred_ID"
.RowSourceType = 5
.height = 24
.left = 80
.style = 2
.top = thisform.ctop
.width = 200
.visible = .t.
.enabled = .t.
ENDWITH
thisform.AddObject('ntxtBox&n', 'TextBox')
WITH thisform.ntxtBox&n
.ControlSource = DrinkItems.Quantity
.top = thisform.ctop
.width = 25
.left = 283
.InputMask = "99"
.value = 1
. visible = .t.
ENDWITH
SKIP
thisform.combonext = thisform.ComboNext + 1
thisform.cTtop = thisform.cTop + 27
SELECT(lnWorkArea)
I am sure that there is something fundamentally wrong with my thinking but I am now at the point of despair! I have tried array as I think there is a problem with the Items record pointer have to move with each new row. I just cannot now see the wood from the trees. I know there is some inconsistency between field names but they are consistent in my code.
Any help pointing me in the right direction would be very much appreciated. I have followed this formum for a while and am amazed at the quality of the members, present company excepted! I have already learned so much.
Michael