Locking Records

A

Asif Rehman

Hello Again

Yesterday I asked if it was possible to lock certain
records in a form but not all of them.

For example I have created a invoicing database and what I
would like to do is when a invoice is created after the
day it is created those records to be locked (kind of a
over night process) and any other previous, but to be able
to create new records when required.

I got help from Andy Cole (Thank You again) I have created
a module with the following code and named it LockCtls:
Option Compare Database

Private Sub LockCtls(blnLock As Boolean)

Me.CustomerID.Locked = blnLock
Me.EmployeeID.Locked = blnLock
Me.InvoiceNumber.Locked = blnLock
Me.OrderDate.Locked = blnLock
Me.RequiredDate.Locked = blnLock
Me.VanID.Locked = blnLock
Me.Subtotal.Locked = blnLock
Me.Vat.Locked = blnLock
Me.Total.Locked = blnLock

End Sub

And I have inserted the following code into my Order
Form's OnCurrent event:
Private Sub Form_Current()

Dim blnLockIt As Boolean

If Date > DateValue(Nz(Me.OrderDate, Date)) Then
blnLockIt = True
Else
blnLockIt = False
End If

LockCtls blnLockIt

End Sub

Now when I go into my orders form I get the following
error and the LockCtls is highlighted,

Expected Variable or Procedure, Not Module.

I have no idea what is wrong, any help will again be much
appreciated.

Kindest Regards
Asif
 
A

Asif Rehman

Hello

I have put the routine in the Forms Module (I think) but
now I get an error Sub or Function not defined again the
LockCtls is highlighted. I have checked the spelling at
thats right.

Thank You

Kind Regards
Asif
 
M

Marshall Barton

Asif said:
Yesterday I asked if it was possible to lock certain
records in a form but not all of them.

For example I have created a invoicing database and what I
would like to do is when a invoice is created after the
day it is created those records to be locked (kind of a
over night process) and any other previous, but to be able
to create new records when required.

I got help from Andy Cole (Thank You again) I have created
a module with the following code and named it LockCtls:
Option Compare Database

Private Sub LockCtls(blnLock As Boolean)

Me.CustomerID.Locked = blnLock
Me.EmployeeID.Locked = blnLock
Me.InvoiceNumber.Locked = blnLock
Me.OrderDate.Locked = blnLock
Me.RequiredDate.Locked = blnLock
Me.VanID.Locked = blnLock
Me.Subtotal.Locked = blnLock
Me.Vat.Locked = blnLock
Me.Total.Locked = blnLock

End Sub

And I have inserted the following code into my Order
Form's OnCurrent event:
Private Sub Form_Current()

Dim blnLockIt As Boolean

If Date > DateValue(Nz(Me.OrderDate, Date)) Then
blnLockIt = True
Else
blnLockIt = False
End If

LockCtls blnLockIt

End Sub

Now when I go into my orders form I get the following
error and the LockCtls is highlighted,

Expected Variable or Procedure, Not Module.

That error usually means that you named the procedure's
module the same as the procedure. Many folks name their
modules with a mod, mdl or bas prefix to avoid this issue.

OTOH, this code looks like it should be in the form's
module. If it is, then I don't see how it could cause that
error. If it's not in the form's maodule, I suggest that
you move it (or rename the module and make the procedure
Public).
 
A

Asif Rehman

Hello

Right I am going to ask the question I know I am going to
look dumb but what is the forms module?.

Kind Regards
Asif
 
A

Andy Cole

Hello Asif

Which version of Access are you using?

If A2K or above then Open your form in design mode then press Alt-F11 to
open the VB Editor which will display the Form's Module. The VB Editor
window Title bar will include Form_yourformname
Code:
At the top of the code, I would expect to see 2 option statements;

Option Compare Database
Option Explicit

Below this you should have the code of the procedure LockCtls;

Private Sub LockCtls(blnLock As Boolean)

Me.CustomerID.Locked = blnLock
... further lines

End Sub

below this you should see code that you have added for the various control
events, including the Form_Current code;

Private Sub Form_Current()

Dim blnLockIt As Boolean

If Date > DateValue(Nz(Me.OrderDate, Date)) Then
blnLockIt = True
Else
blnLockIt = False
End If
LockCtls blnLockIt

End Sub

Now select Compile... from the Debug menu

You shouldn't get any errors.  Close the VB Editor window to return to your
form in design mode.  Close the form and save the changes when prompted

Try running the Form

HTH

Andy
 
A

Asif Rehman

Hello

Well its a good job I'm not in charge of nuclear weapons
or anything, sorry for being so dumb thanks alot for your
help.

Kind Regards
Asif
-----Original Message-----
Hello Asif

Which version of Access are you using?

If A2K or above then Open your form in design mode then press Alt-F11 to
open the VB Editor which will display the Form's Module. The VB Editor
window Title bar will include Form_yourformname
Code:
At the top of the code, I would expect to see 2 option statements;

Option Compare Database
Option Explicit

Below this you should have the code of the procedure LockCtls;

Private Sub LockCtls(blnLock As Boolean)

Me.CustomerID.Locked = blnLock
... further lines

End Sub

below this you should see code that you have added for the various control
events, including the Form_Current code;

Private Sub Form_Current()

Dim blnLockIt As Boolean

If Date > DateValue(Nz(Me.OrderDate, Date)) Then
blnLockIt = True
Else
blnLockIt = False
End If
LockCtls blnLockIt

End Sub

Now select Compile... from the Debug menu

You shouldn't get any errors.  Close the VB Editor window to return to your
form in design mode.  Close the form and save the changes when prompted

Try running the Form

HTH

Andy


[QUOTE="Asif Rehman"]
Hello

I have put the routine in the Forms Module (I think) but
now I get an error Sub or Function not defined again the
LockCtls is highlighted.   I have checked the spelling at
thats right.

Thank You

Kind Regards
Asif
 (the
module where the[/QUOTE]


.
[/QUOTE]
 
A

Andy Cole

No problem - glad to be of help

Andy

Asif Rehman said:
Hello

Well its a good job I'm not in charge of nuclear weapons
or anything, sorry for being so dumb thanks alot for your
help.

Kind Regards
Asif
-----Original Message-----
Hello Asif

Which version of Access are you using?

If A2K or above then Open your form in design mode then press Alt-F11 to
open the VB Editor which will display the Form's Module. The VB Editor
window Title bar will include Form_yourformname
Code:
At the top of the code, I would expect to see 2 option statements;

Option Compare Database
Option Explicit

Below this you should have the code of the procedure LockCtls;

Private Sub LockCtls(blnLock As Boolean)

Me.CustomerID.Locked = blnLock
... further lines

End Sub

below this you should see code that you have added for the various control
events, including the Form_Current code;

Private Sub Form_Current()

Dim blnLockIt As Boolean

If Date > DateValue(Nz(Me.OrderDate, Date)) Then
blnLockIt = True
Else
blnLockIt = False
End If
LockCtls blnLockIt

End Sub

Now select Compile... from the Debug menu

You shouldn't get any errors.  Close the VB Editor window to return to your
form in design mode.  Close the form and save the changes when prompted

Try running the Form

HTH

Andy


[QUOTE="Asif Rehman"]
Hello

I have put the routine in the Forms Module (I think) but
now I get an error Sub or Function not defined again the
LockCtls is highlighted.   I have checked the spelling at
thats right.

Thank You

Kind Regards
Asif

-----Original Message-----
Asif

The LockCtls routine should be in the *Forms* module (the
module where the
Form_Current routine is), not in a new module.  Put the
code at the top of
the Forms module (just below the Option... statements)
and delete the new
module (called LockCtls)

HTH

Andy

Hello Again

Yesterday I asked if it was possible to lock certain
records in a form but not all of them.

For example I have created a invoicing database and
what I
would like to do is when a invoice is created after the
day it is created those records to be locked (kind of a
over night process) and any other previous, but to be
able
to create new records when required.

I got help from Andy Cole (Thank You again) I have
created
a module with the following code and named it LockCtls:
Option Compare Database

Private Sub LockCtls(blnLock As Boolean)

Me.CustomerID.Locked = blnLock
Me.EmployeeID.Locked = blnLock
Me.InvoiceNumber.Locked = blnLock
Me.OrderDate.Locked = blnLock
Me.RequiredDate.Locked = blnLock
Me.VanID.Locked = blnLock
Me.Subtotal.Locked = blnLock
Me.Vat.Locked = blnLock
Me.Total.Locked = blnLock

End Sub

And I have inserted the following code into my Order
Form's OnCurrent event:
Private Sub Form_Current()

Dim blnLockIt As Boolean

If Date > DateValue(Nz(Me.OrderDate, Date)) Then
blnLockIt = True
Else
blnLockIt = False
End If

LockCtls blnLockIt

End Sub

Now when I go into my orders form I get the following
error and the LockCtls is highlighted,

Expected Variable or Procedure, Not Module.

I have no idea what is wrong, any help will again be
much
appreciated.

Kindest Regards
Asif





.
[/QUOTE]


.
[/QUOTE][/QUOTE]
 

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