G
Guest
I have a form (frmDocuments) with a subform (sfrmDocsOnly) that is opened by
double-clicking a record selector from a subdatasheet on another form. When
the new form is opened, I want it to check to see if any records are returned
in the subform and, if not, add a new record with the [ClientID]
auto-populated. It appears to work fine. The frmDocuments opens and it
appears to have a new record added with sfrmDocsOnly and the [ClientID] is
auto-populated once I start typing. However, as soon as I move, even before
I can start typing, I get the following error:
"The field 'tblDocuments.Doc Type' cannot contain a Null value because the
Required property for this field is set to True. Enter a value in this
field."
It is referring to the first field that I must fill in, and it is a required
field, and needs to be. It appears that the record is saving before I even
enter anything. If I click "OK" on the error message I can continue to add
the record, but when I go to the next record or exit the form, I get the same
message. I can't figure this out at all.
Following is the code for the DblClick event:
Private Sub Form_DblClick(Cancel As Integer)
Dim stDocName As String
Dim stLinkCriteria As String
Dim stOpenArgs As String
stDocName = "sfrmDocuments-NewClients"
stLinkCriteria = "[ClientID] =" & Me![Client ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria, , , Me.[ClientID]
End Sub
And following is the code in the Load event:
Private Sub Form_Load()
If Len(Me.OpenArgs & "") > 0 Then
DoCmd.GoToRecord , , acNewRec
Me.[ClientID] = Me.OpenArgs
End If
End Sub
Can anyone help me figure this out? I have been searching the help files,
books and the discussion group with no luck. Any help is greatly appreciated.
If further information is needed, please advise.
Thanks in advance.
double-clicking a record selector from a subdatasheet on another form. When
the new form is opened, I want it to check to see if any records are returned
in the subform and, if not, add a new record with the [ClientID]
auto-populated. It appears to work fine. The frmDocuments opens and it
appears to have a new record added with sfrmDocsOnly and the [ClientID] is
auto-populated once I start typing. However, as soon as I move, even before
I can start typing, I get the following error:
"The field 'tblDocuments.Doc Type' cannot contain a Null value because the
Required property for this field is set to True. Enter a value in this
field."
It is referring to the first field that I must fill in, and it is a required
field, and needs to be. It appears that the record is saving before I even
enter anything. If I click "OK" on the error message I can continue to add
the record, but when I go to the next record or exit the form, I get the same
message. I can't figure this out at all.
Following is the code for the DblClick event:
Private Sub Form_DblClick(Cancel As Integer)
Dim stDocName As String
Dim stLinkCriteria As String
Dim stOpenArgs As String
stDocName = "sfrmDocuments-NewClients"
stLinkCriteria = "[ClientID] =" & Me![Client ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria, , , Me.[ClientID]
End Sub
And following is the code in the Load event:
Private Sub Form_Load()
If Len(Me.OpenArgs & "") > 0 Then
DoCmd.GoToRecord , , acNewRec
Me.[ClientID] = Me.OpenArgs
End If
End Sub
Can anyone help me figure this out? I have been searching the help files,
books and the discussion group with no luck. Any help is greatly appreciated.
If further information is needed, please advise.
Thanks in advance.