If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
|
Thread Tools | Display Modes |
#11
|
|||
|
|||
Recipe form
Thank you, perfect. Code wokred beautifully
"John W. Vinson" wrote in message ... On Wed, 3 Feb 2010 18:45:01 -0500, "DF59" wrote: ok, my conrolname is CatCount and the field names of my Recipes table ar as follows: 1) RecipeID Autonumber 2) CatCount Number 3) RecipeName Text 4) RecieDescription Text 5) FoodCategoryID Number 6) TimetoPrepare Text 7) CookTime Text 8) NumberofServings Number 9) Ingredients Memo 10) Instructions Memo 11) BookIncluded YesNo 12) Picture Ole Object If I read John's last reply correctly, my code should look something like this: Me!CatCount = Count(CatCount = Tables!Recipes!{FoodCategoryID] ) + 1 I tried a setval macro to do this but the objects were not resolved correctly. There are a few ways to do this, but I'd suggest using VBA code, not a Macro; for a one-user system (where you won't have different users competing for new ID numbers) you could use the AfterUpdate event of the FoodCategoryID combo box. View its Properties; on the After Event property on the Events tab click the ... icon and choose Code Builder. Edit the code to Private Sub FoodCategoryID_AfterUpdate Me!CatCount = NZ(DMax("CatCount", "Recipes", _ "FoodCategoryID = " & Me!FoodCategoryID)) + 1 End Sub This will look up the largest existing CatCount for this food category (and get a 0 if there aren't any yet); add 1, and store the result in the CatCount field. I like this better than counting records because that count will be off if you should ever delete a recipe. -- John W. Vinson [MVP] |
#12
|
|||
|
|||
Recipe form
On Thu, 4 Feb 2010 20:32:47 -0500, "DF59" wrote:
Thank you, perfect. Code wokred beautifully Glad to have been of help. Payment in the form of a good vegetarian recipe would be welcome... g -- John W. Vinson [MVP] |
|
Thread Tools | |
Display Modes | |
|
|