Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2008

    Unanswered: Another recipe database conundrum - temporarily doubling recipe ingredients

    So, I may be getting really far beyond my skill level here. I'll explain what I'm wanting to do and the code I have and you can tell me to forget it if it's too over the top.

    Some basics about my table/query/form structure:
    Recipe table/form - holds recipe header information
    Recipe ingredients/subform - holds ingredients by recipe but must be chosen from ingredients table
    Ingredients table/form - holds all ingredients or products you might find at Target
    Weekly menu table/form - Allows you to create your weekly menu by choosing recipes; Recipes are chosen based on menu categories (main course, sides, dessert, etc.)

    There's more, but I think you'll get the idea. I started this with a basic recipe template I found off of Microsoft. It came with a multiply command on the main recipe form that allowed you to double the ingredients and serving size for that recipe. Problem is, that's a permanent change. If you double a recipe once, you have to remember to go back and un-double it if you want to do a single version.

    On of my DB features is that when you pick recipes for the week, it creates a shopping list based on the ingredients in the Recipe Ingredients table. So, the doubling is important not just to make sure I make the recipe correctly but also to make sure I buy enough stuff for it.

    I have several pieces of code that run at the beginning of a new week to delete out the prior weekly menu and the prior week's shopping list. Is there any way I can record which recipes I doubled the week before and "un-double" them at the start of a new week as a part of the process? Does that even make sense?

    In case it helps, here's the multiply code that came with the recipe template. I can generally follow the code but don't understand all of it. It's a pop-up dialog box so that you can actually triple or halve or whatever.

    Dim rst As Recordset
    Dim dblFactor As Double

    On Error GoTo Multiply_Err
    DoCmd.OpenForm "Multiply Dialog", , , , , acDialog

    If Not IsLoaded("Multiply Dialog") Then
    Exit Sub
    End If

    If IsNull(Forms![Multiply Dialog]![Factor]) Or Forms![Multiply Dialog]![Factor] = 0 Then
    DoCmd.Close acForm, "Multiply Dialog"
    Exit Sub
    End If

    DoCmd.Hourglass True
    dblFactor = CDbl(Forms![Multiply Dialog]![Factor])
    Set rst = Me![Recipes Subform].Form.RecordsetClone
    While (Not (rst.EOF))
    rst![Quantity] = rst![Quantity] * dblFactor
    Me![NumberofServings] = Forms![RECIPES]![NumberofServings] * dblFactor

    DoCmd.Close acForm, "Multiply Dialog"
    DoCmd.Hourglass False
    Exit Sub

    MsgBox Err.Description
    Resume Multiply_Exit

  2. #2
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    A recipie exists it should only be changed if you modify the recipie itself
    waht you are talking about is a batch size.

    A recipie should be capable of being scaled (up or down), although there are always going to be problems where you have a recipie which uses one offs, rather than say a weight. eg those that use 1 egg, or 1 500gram Chicken, you need to scale in whole units for those cases.

    The place to store that is in say your menu plan, allow for either a bigger batch size, or allow multiple instances of that menu item, or add a quantity on the menu, and then create your shopping list based on that.

  3. #3
    Join Date
    Mar 2008
    Healdem - Thanks. I think this was a classic example of me overthinking it. It took me a few minutes for figure out the expression, but I think I got it!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts