create new record in sub form

T

tony wong

i have the following code in the sub form
Forms!FrmApplicant!Status is the main form object

when i create a record in the main form, it is blank (not allow me to add)
in sub form.
when i go back to previous record (NOT Closed) and go forward, then the
newly created record is allowed to add in sub form.

the blank situation is only appeared when i create a new record
and at that time when i go to create the new record, i am at a "Closed"
record of the main form.
it seems the newly created record use the restriction of the previous
record.

i have been struggled at this issue for a long time. Grateful if you could
help me or give me hints to troubleshoot. Thanks a lot.

***********************************
Private Sub Form_Current()

If Forms!FrmApplicant!Status = "Closed" Then
Me.AllowEdits = False
Me.AllowDeletions = False
Me.AllowAdditions = False

Else
Me.AllowEdits = True
Me.AllowDeletions = True
Me.AllowAdditions = True
End If

End Sub
 
S

Squirrel

Hi Tony,

Am no expert, read these messages in order to learn, but note that - in your
Form_Current - you're not checking for NULL. Might it be worth trying this
sort of logic:
Private Sub Form_Current()
If IsNull(Forms!FrmApplicant!Status) Then
Me.AllowEdits = True
Me.AllowDeletions = True
Me.AllowAdditions = True
ElseIf Forms!FrmApplicant!Status = "Closed" Then
Me.AllowEdits = False
Me.AllowDeletions = False
Me.AllowAdditions = False

Else
Me.AllowEdits = True
Me.AllowDeletions = True
Me.AllowAdditions = True
End If

End Sub

If that doesn't help maybe try adding some similar logic in the BeforeInsert
event.

HTH -Linda
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top