Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2002
    Location
    Hamilton,Ontario
    Posts
    132

    Unanswered: DoCmd.OpenForm.....

    Hi Everyone
    I was Wondering how to open up form with specific record. I want to load this form where FinishedProduct is equal to RecipeItemNo.FinishedProdcut is field on that form.
    here is non Working code which gives me error that FinishedProduct is not known.


    If response = ID_YES Then
    'it opens the form but not where Finished Product =RecipeItemNo
    'how Can I open the Form with Specific record?
    DoCmd.OpenForm "zInventoryRecipes", acNormal,,[FinishedProduct]=RecipeitemNo
    Else
    Exit Function
    End If


    Thanx in Advance.

  2. #2
    Join Date
    Nov 2002
    Location
    Hamilton,Ontario
    Posts
    132

    Re: DoCmd.OpenForm.....

    Took me sometime but eventually i figured out Here is the whole function .I hope it helps.

    'Making A function that will Add RecipeRipped Item Number into Inventory Recipes and into Coversion Factor Table
    Public Function AddRecipeRippedToInventoryRecipesTable(RecipeitemN o As String, Form As Form) As String
    'Error Handler
    If ErrorTrapping = True Then
    On Error GoTo AddRecipeRippedToInventoryRecipeTable_Err_Handler
    End If
    'Declaration of variables
    Dim curdb As Database
    Dim adrsAddRecipe As Recordset
    Dim SQLStmt As String
    Dim openedForm As Form
    Set curdb = CurrentDb()
    'Accessing Table [Inventory Recipes]
    SQLStmt = "Select * from [Inventory Recipes] where [FinishedProduct]='" & RecipeitemNo & "'"
    Set adrsAddRecipe = curdb.OpenRecordset(SQLStmt, dbOpenDynaset)
    'Checking if Item Exists
    If adrsAddRecipe.EOF = True Then
    MsgBox "Item Number Does Not Exist in Inventory Recipe Table", vbCritical
    Exit Function
    Else
    response = MsgBox("Item Does Not Exist In Inventory Recipes Table Under RippedMaterial Field, Would You Like to Add It Now?", vbYesNo, "Adding Ripped item Number to Inventory Recipes")
    If response = ID_YES Then
    'Using The Above Query to open form with specific Record
    DoCmd.OpenForm "zInventoryRecipes", acNormal, SQLStmt
    Else
    Exit Function
    End If
    End If
    'Explicitly Closing All Ojbects
    adrsAddRecipe.Close
    Set adrsAddRecipe = Nothing
    curdb.Close
    Set curdb = Nothing
    Exit Function
    'Displays Appropriate Error Message
    AddRecipeRippedToInventoryRecipeTable_Err_Handler:
    DispError "Adding Ripped Item in Inventory Recipes Table", "yworkOrder2"
    Exit Function
    End Function

  3. #3
    Join Date
    Sep 2002
    Location
    Land of OZ
    Posts
    173

    Re: DoCmd.OpenForm.....

    Originally posted by VBAPROGRAMMER
    Hi Everyone
    I was Wondering how to open up form with specific record. I want to load this form where FinishedProduct is equal to RecipeItemNo.FinishedProdcut is field on that form.
    here is non Working code which gives me error that FinishedProduct is not known.


    If response = ID_YES Then
    'it opens the form but not where Finished Product =RecipeItemNo
    'how Can I open the Form with Specific record?
    DoCmd.OpenForm "zInventoryRecipes", acNormal,,[FinishedProduct]=RecipeitemNo
    Else
    Exit Function
    End If


    Thanx in Advance.

    Assumably that the ReceiptItemNo is a field on a form holding the value.
    Lets assume that on Form1 there is field called ReceiptItemNo.
    Click a button and user decides that they want to open specific record

    DoCmd.OpenForm "zInventoryRecipes", acNormal,,"[FinishedProduct] =" & frm_form1.RecipeitemNo

    I believe that you are missing some quotes as FinishedProduct is a feild name on the form that you are opening.

    Cheers
    Mona
    ________________________________
    Life is too short to be sane or sensible. Weird people rule and normal people suck

Posting Permissions

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