OnChange or BeforeUpdate or AfterUpdate event?

P

PayeDoc

Hello All

I have a split FE/BE mdb, with a 'master' FE that is on the server - mapped
as Z drive - that I work on, and various copies of the FE on various PCs
that the users work on. I need to prevent a particular combobox selection
("PayeDoc") from being made if the user is working on one of the local FE
copies: only a user working on the 'master' FE (on the Z drive) should be
able to select "PayeDoc". I have tried using the code below as the OnChange,
and the BeforeUpdate, and the AfterUpdate event of the combobox, but none of
these has worked - no errors, but the ability to select "PayeDoc" has not
been affected.

Private Sub prac_name_BeforeUpdate(Cancel As Integer)
If [CurrentProject].[path] <> "Z:" And [Forms]![frm x main]![prac name] =
"PayeDoc" Then
Me.Undo
MsgBox ("Condition met")
End If
End Sub

I know that the condition is being satisfied appropriately, because the
"Condition met" message is displayed as expected. It's the Me.Undo that
isn't happening.

What have I done wrong - and how can I achieve what I need?

Hope someone can help.
Many thanks
Leslie Isaacs
 
D

Douglas J. Steele

CurrentProject.Path shouldn't require the square brackets, but more
importantly, it's going to return a full path, not just Z:

Try:

Private Sub prac_name_BeforeUpdate(Cancel As Integer)

If Left(CurrentProject.path, 1) <> "Z" And _
[Forms]![frm x main]![prac name] ="PayeDoc" Then
Me.Undo
MsgBox "Condition met"
End If

End Sub
 
P

PayeDoc

Douglas

Brilliant - it was as simple as that!!

Many thanks for your help
Les


Douglas J. Steele said:
CurrentProject.Path shouldn't require the square brackets, but more
importantly, it's going to return a full path, not just Z:

Try:

Private Sub prac_name_BeforeUpdate(Cancel As Integer)

If Left(CurrentProject.path, 1) <> "Z" And _
[Forms]![frm x main]![prac name] ="PayeDoc" Then
Me.Undo
MsgBox "Condition met"
End If

End Sub

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


PayeDoc said:
Hello All

I have a split FE/BE mdb, with a 'master' FE that is on the server -
mapped
as Z drive - that I work on, and various copies of the FE on various PCs
that the users work on. I need to prevent a particular combobox selection
("PayeDoc") from being made if the user is working on one of the local FE
copies: only a user working on the 'master' FE (on the Z drive) should be
able to select "PayeDoc". I have tried using the code below as the
OnChange,
and the BeforeUpdate, and the AfterUpdate event of the combobox, but none
of
these has worked - no errors, but the ability to select "PayeDoc" has not
been affected.

Private Sub prac_name_BeforeUpdate(Cancel As Integer)
If [CurrentProject].[path] <> "Z:" And [Forms]![frm x main]![prac name] =
"PayeDoc" Then
Me.Undo
MsgBox ("Condition met")
End If
End Sub

I know that the condition is being satisfied appropriately, because the
"Condition met" message is displayed as expected. It's the Me.Undo that
isn't happening.

What have I done wrong - and how can I achieve what I need?

Hope someone can help.
Many thanks
Leslie Isaacs
 

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