I would like to code on the click of a command button that checks for the existence of a record. If it exists then open a form to display the data. If the record does not exist then open a form and set a field based on the value of a variable and default the remaining values.
My on click code looks like:
RecordExists = DCount("ClarityID", "Tbl-ProjectComplexityList", stLinkCriteria)
If RecordExists > 0 Then
MsgBox "complexity record exists", vbOKOnly
DoCmd.OpenForm NextForm, acNormal, , stLinkCriteria, , acWindowNormal
Else
MsgBox "complexity record does not exists", vbOKOnly
DoCmd.OpenForm "Frm-ProjectComplexityNew", acNormal, , , acFormAdd, acWindowNormal
End If
This seems to get seem to get me to the correct form. The problem I have is that the "Frm-ProjectComplexityNew" is blank and it does not like when I try to assign values On Open
Field1 = Variable.Value
Suggestions on how to populate that new record with default/variable data?
My on click code looks like:
RecordExists = DCount("ClarityID", "Tbl-ProjectComplexityList", stLinkCriteria)
If RecordExists > 0 Then
MsgBox "complexity record exists", vbOKOnly
DoCmd.OpenForm NextForm, acNormal, , stLinkCriteria, , acWindowNormal
Else
MsgBox "complexity record does not exists", vbOKOnly
DoCmd.OpenForm "Frm-ProjectComplexityNew", acNormal, , , acFormAdd, acWindowNormal
End If
This seems to get seem to get me to the correct form. The problem I have is that the "Frm-ProjectComplexityNew" is blank and it does not like when I try to assign values On Open
Field1 = Variable.Value
Suggestions on how to populate that new record with default/variable data?