P
paxdak
I have a form that I want to restrict access to.
I only want it to be open from another form and NOT from the DB window.
The other forms change the recordset to a specific record.
From the database window the form opens with entire record set. I don't
want to allow
wholesale changes on all records from this form.
I thought that I could check the RecordCount of the form, and close the
form
if the recordset did not equal 1. I tried the below code. I also tried
the code in the
Form_Load event, but it didn;t work consistently there either. The form
still opens up
from the DB window. If I change to design mode, then view mode, the
routine is run.
What event do I need to put the code into?
or is there a better way to do this?
Private Sub Form_Open(Cancel As Integer)
'Only open if one record is selected
If Me.Form.RecordsetClone.RecordCount <> 1 Then
DoCmd.Close acForm, Me.Name, acSaveNo
Else
'Do some other things
End If
End Sub
I only want it to be open from another form and NOT from the DB window.
The other forms change the recordset to a specific record.
From the database window the form opens with entire record set. I don't
want to allow
wholesale changes on all records from this form.
I thought that I could check the RecordCount of the form, and close the
form
if the recordset did not equal 1. I tried the below code. I also tried
the code in the
Form_Load event, but it didn;t work consistently there either. The form
still opens up
from the DB window. If I change to design mode, then view mode, the
routine is run.
What event do I need to put the code into?
or is there a better way to do this?
Private Sub Form_Open(Cancel As Integer)
'Only open if one record is selected
If Me.Form.RecordsetClone.RecordCount <> 1 Then
DoCmd.Close acForm, Me.Name, acSaveNo
Else
'Do some other things
End If
End Sub