Hi I have a form with a Sub form that is a continous form, on this sub form there is a button that should allow users to add a country of origin for an ingredient, I have copied and pasted code and modified it to fit to open the form showing any exisiting info and a new line, or open it in add mode if nothing exisiting.
However when there is no existing info the form states "you can't assign a value to this object".
Any thought please?
Cheers
Code:
Private Sub Sub_Comp_Ing_COO_Click()
On Error GoTo Err_Sub_Comp_Ing_COO_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "S_frmSubComponents_in_Components"
If IsNull(DLookup("SubComp_in_ingID", "tblSubComp_COO", "SubComp_in_ingID=" & Me![SubComp_in_ingID])) Then
DoCmd.OpenForm "frmSubComp_COO", , , , acFormAdd
Forms!frmRMIngDeclaration!S_frmSubComponents_in_Components.Form.SubComp_in_ingID = Me![SubComp_in_ingID]
Else
DoCmd.OpenForm "frmSubComp_COO", , , "SubComp_in_ingID=" & Me![SubComp_in_ingID]
End If
Exit_Sub_Comp_Ing_COO_Click:
Exit Sub
Err_Sub_Comp_Ing_COO_Click:
MsgBox Err.Description
Resume Exit_Sub_Comp_Ing_COO_Click
End Sub