Open form in exclusive mode

P

Paulo Ferreira

Hello,

Can someone tell me how to open a form in exlusive mode.
Many thanks.

Paulo Ferreira
 
K

Klatuu

What do you mean by exclusive mode? Allow no other user to open an instance
of the form? Allow no other user access to the data that provides the form's
recordset?
But, more curiously, what is the purpose of doing this?
 
P

Paulo Ferreira

As the form is used for two persons to add records, I would like to limit
the access to that form to one at a time.
Thanks
 
K

Klatuu

I have never done this. I would be cautious about doing so, because it could
get messed up so that neither user could open the form. However, my first
idea would be to create a table with one record and one field. Then use the
Open event of the form to check to see if the form is open by someone else
before allowing the form to continue opening.

Dim rst As Recordset

Set rst = Currentdb.OpenRecordset("TableName")

If rst![InUse] = "Yes" Then
MsgBox "This Form Is not Available"
Cancel = True
Else
rst.Edit
rst![InUse] = "Yes"
End If
rst.Close
Set rst = Nothing

And in the Close event of the form:

Currentdb.Execute("UPDATE MyTable SET InUse = 'No';"), dbFailOnError
 
P

Paulo Ferreira

Now, it stops on line "If rst![InUse] = "Yes" Then" with "runtime error
3021".
More help please.
Thanks.

Paulo Ferreira


Klatuu said:
I have never done this. I would be cautious about doing so, because it
could
get messed up so that neither user could open the form. However, my
first
idea would be to create a table with one record and one field. Then use
the
Open event of the form to check to see if the form is open by someone else
before allowing the form to continue opening.

Dim rst As Recordset

Set rst = Currentdb.OpenRecordset("TableName")

If rst![InUse] = "Yes" Then
MsgBox "This Form Is not Available"
Cancel = True
Else
rst.Edit
rst![InUse] = "Yes"
End If
rst.Close
Set rst = Nothing

And in the Close event of the form:

Currentdb.Execute("UPDATE MyTable SET InUse = 'No';"), dbFailOnError



Paulo Ferreira said:
As the form is used for two persons to add records, I would like to limit
the access to that form to one at a time.
Thanks
 
K

Klatuu

Do you have any records in rst![InUse]?
Normally, when you open a recordset, it is positioned on the first record in
the recordset. In this case, there should always be one record.

Paulo Ferreira said:
Now, it stops on line "If rst![InUse] = "Yes" Then" with "runtime error
3021".
More help please.
Thanks.

Paulo Ferreira


Klatuu said:
I have never done this. I would be cautious about doing so, because it
could
get messed up so that neither user could open the form. However, my
first
idea would be to create a table with one record and one field. Then use
the
Open event of the form to check to see if the form is open by someone else
before allowing the form to continue opening.

Dim rst As Recordset

Set rst = Currentdb.OpenRecordset("TableName")

If rst![InUse] = "Yes" Then
MsgBox "This Form Is not Available"
Cancel = True
Else
rst.Edit
rst![InUse] = "Yes"
End If
rst.Close
Set rst = Nothing

And in the Close event of the form:

Currentdb.Execute("UPDATE MyTable SET InUse = 'No';"), dbFailOnError



Paulo Ferreira said:
As the form is used for two persons to add records, I would like to limit
the access to that form to one at a time.
Thanks


"Klatuu" <[email protected]> escreveu na mensagem
What do you mean by exclusive mode? Allow no other user to open an
instance
of the form? Allow no other user access to the data that provides the
form's
recordset?
But, more curiously, what is the purpose of doing this?

:

Hello,

Can someone tell me how to open a form in exlusive mode.
Many thanks.

Paulo Ferreira
 

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