Hi guys! I need some help..
I've created a stock managment database that will be used by a laboratory I work for... However, I'm stuck on the last implementation, and that's where you guys come in...
Side Note: As this is a big and ambitious project, it's also my first. So bare with me.
Let's first get the context right what I am working with..
To start of simple I have created a list of products (tbl_stk_Productenlijst). Users fill in a form (frm_stk_IngaveStock) with a subform (sfrm_stk_IngaveStock) to add or remove products from the inventory. The form and subform is connected respectively to tbl_stk_Transacties and tbl_stk_TransactieDetails. This works perfectly and is used to add or deplete products sush as gloves, masks, chemicals.
Apart from entering 'normal' products, there is also a form for preparing preparations. The form is bound to a SELECT query (qry_ber_Aanmaakbereiding) that combines two tables (tbl_ber_AanmaakProducten and tbl_ber_Recepten). There are also some calculated fields in this query that calculate the amount of product (found in the recipes, these building blocks are then found in the list of Products) used. More on that later.
On the form where the input is given for the preparation, I have put a button with an 'on click' event. This should be either a Macro or VBA. The code is as follows:
DoCmd.OpenForm "frm_stk_IngaveStock", acNormal, "", "", acAdd, acNormal #This opens the form wich is used for all other stock inputs
Forms!frm_stk_IngaveStock!Per_INI = Forms!frm_ber_AanmaakBereiding!Per_INI #This passes through the same coworker
Forms!frm_stk_IngaveStock!Trs_TransactieType = 2 #This sets the transaction as a depletion
Forms!frm_stk_IngaveStock!sfrm_trs_IngaveStock.Form!Prd_ID = Forms!frm_ber_AanmaakBereiding!Rcp_Prd1 #This passes trough the first product of the recipe
Forms!frm_stk_IngaveStock!sfrm_trs_IngaveStock.Form!Trs_Hoeveelheid = Forms!frm_ber_AanmaakBereiding!rcp_Prd1QtyP #This passes trough the used amount of the first product
DoCmd.RunCommand acCmdSaveRecord #Just as a placeholder, will be deleted
The code above works as it should be. The problem occurs in the following, with the other product: As a path I have either used [Forms]![frm_stk_IngaveStock]![sfrm_trs_IngaveStock] and [Forms]![frm_stk_IngaveStock]![sfrm_trs_IngaveStock], both result in the error : The object '[Forms]![frm_stk_IngaveStock]![sfrm_trs_IngaveStock]' isn't open.
In essence I just want to add a new record to the subform and pass the data from the next product in the recipe. There is a max of 6 products per recipe. This is the code I used...
Me.[Forms]![frm_stk_IngaveStock]![sfrm_trs_IngaveStock].SetFocus
DoCmd.GoToRecord acForm, "[Forms]![frm_stk_IngaveStock]![sfrm_trs_IngaveStock]", acNewRec
If (Eval("[Forms]![frm_ber_AanmaakBereiding]![Rcp_Prd2] Is Not Null")) Then
Forms!frm_stk_IngaveStock!sfrm_trs_IngaveStock.Form!Prd_ID = Forms!frm_ber_AanmaakBereiding!Rcp_Prd2
Forms!frm_stk_IngaveStock!sfrm_trs_IngaveStock.Form!Trs_Hoeveelheid = Forms!frm_ber_AanmaakBereiding!rcp_Prd2QtyP
End If
Can someone help me please? I'm sorry the names of the access objects are in Dutch
I've created a stock managment database that will be used by a laboratory I work for... However, I'm stuck on the last implementation, and that's where you guys come in...
Side Note: As this is a big and ambitious project, it's also my first. So bare with me.
Let's first get the context right what I am working with..
To start of simple I have created a list of products (tbl_stk_Productenlijst). Users fill in a form (frm_stk_IngaveStock) with a subform (sfrm_stk_IngaveStock) to add or remove products from the inventory. The form and subform is connected respectively to tbl_stk_Transacties and tbl_stk_TransactieDetails. This works perfectly and is used to add or deplete products sush as gloves, masks, chemicals.
Apart from entering 'normal' products, there is also a form for preparing preparations. The form is bound to a SELECT query (qry_ber_Aanmaakbereiding) that combines two tables (tbl_ber_AanmaakProducten and tbl_ber_Recepten). There are also some calculated fields in this query that calculate the amount of product (found in the recipes, these building blocks are then found in the list of Products) used. More on that later.
On the form where the input is given for the preparation, I have put a button with an 'on click' event. This should be either a Macro or VBA. The code is as follows:
DoCmd.OpenForm "frm_stk_IngaveStock", acNormal, "", "", acAdd, acNormal #This opens the form wich is used for all other stock inputs
Forms!frm_stk_IngaveStock!Per_INI = Forms!frm_ber_AanmaakBereiding!Per_INI #This passes through the same coworker
Forms!frm_stk_IngaveStock!Trs_TransactieType = 2 #This sets the transaction as a depletion
Forms!frm_stk_IngaveStock!sfrm_trs_IngaveStock.Form!Prd_ID = Forms!frm_ber_AanmaakBereiding!Rcp_Prd1 #This passes trough the first product of the recipe
Forms!frm_stk_IngaveStock!sfrm_trs_IngaveStock.Form!Trs_Hoeveelheid = Forms!frm_ber_AanmaakBereiding!rcp_Prd1QtyP #This passes trough the used amount of the first product
DoCmd.RunCommand acCmdSaveRecord #Just as a placeholder, will be deleted
The code above works as it should be. The problem occurs in the following, with the other product: As a path I have either used [Forms]![frm_stk_IngaveStock]![sfrm_trs_IngaveStock] and [Forms]![frm_stk_IngaveStock]![sfrm_trs_IngaveStock], both result in the error : The object '[Forms]![frm_stk_IngaveStock]![sfrm_trs_IngaveStock]' isn't open.
In essence I just want to add a new record to the subform and pass the data from the next product in the recipe. There is a max of 6 products per recipe. This is the code I used...
Me.[Forms]![frm_stk_IngaveStock]![sfrm_trs_IngaveStock].SetFocus
DoCmd.GoToRecord acForm, "[Forms]![frm_stk_IngaveStock]![sfrm_trs_IngaveStock]", acNewRec
If (Eval("[Forms]![frm_ber_AanmaakBereiding]![Rcp_Prd2] Is Not Null")) Then
Forms!frm_stk_IngaveStock!sfrm_trs_IngaveStock.Form!Prd_ID = Forms!frm_ber_AanmaakBereiding!Rcp_Prd2
Forms!frm_stk_IngaveStock!sfrm_trs_IngaveStock.Form!Trs_Hoeveelheid = Forms!frm_ber_AanmaakBereiding!rcp_Prd2QtyP
End If
Can someone help me please? I'm sorry the names of the access objects are in Dutch