How to populate fields on a new record

wchernock

Registered User.
Local time
Yesterday, 19:45
Joined
Jun 18, 2007
Messages
28
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?
 
Try setting your values in the OnLoad event instead of the Open event.
 
While troubleshooting I even created a populated button and set all of the field values. They display on the form, but when Itry to save the record, it does not save and gives no errors.
 
Is it a bound form and are all of the controls bound to fields? What code are you using to save the record?
 

Users who are viewing this thread

Back
Top Bottom