Invalid Outside Procedure Error Message ***HELP ;)

M

Mellissa

Hi,

I created a database on Access over a year ago in which my entire department
utilizes but it has always been very basic. Currently, I am trying to add
things like "Date/Time Modified" and I am learning about expressions and code
building in modules however, I am finding it very difficult.

One questions I have is the following:

I if have a check box field named "select" and a Date Updated field right
beside the check box named "DateSelect" how and where to I go to ensure that
as soon as someone checks that box, a date and time is inserted in the
DateSelect field ??

I have tried the following:

If Checked=True Then DateFieldName=Now() Else DateFieldName=Null End If.

But this doesnt seem to work. I dont know where to put it or wher to
substitute my field names I guess because I have not had any luck ;(

Also, when I have tried it though, in the module, I continue to get the error
message "Invalid Outside Procedure" and always, the DateModified = Date is
always highlighted when I get this error message???

Any ideas would be AWESOME and I would love you to death. I have a meeting
with my boss in a couple days to present this but I am totally lost at the
moment so I'm a little desperate......Thank you so much in advance ;)

Mellissa
 
A

Allen Browne

Mellisa, SELECT is a reserved word for queries.
You are likely to run into problems if you don't rename the field.
For this example, I will assume you have renamed it to IsSelected in your
table.

Then:
1. Open your form in design view.

2. Make sure you change both the Control Source of the check box and also
its Name property to IsSelected (or whatever you named your field to.)

3. Set the After Update property for this check box to:
[Event Procedure]

4. Click the Build button beside this property.
Access opens the code window.
Set up the code so it looks like this:

Private Sub IsSelected_AfterUpdate()
If Me.IsSelected = True Then
Me.DateFieldName = Now()
Else
Me.DateFieldName = Null
End If
End Sub

5. Choose Compile in the Debug menu, to ensure Access understands it. Fix
any errors, and repeat until it compiles without error.

Your code is now inside a procedure (i.e. the Sub ... End Sub.)

And here is a list of the field names to avoid:
http://allenbrowne.com/AppIssueBadWord.html
You may wish to refer to that list when creating fields.
 
M

Mellissa via AccessMonster.com

Hi Allen,

Thank you sooooo much. It worked beautifully ;)

I am sure I will be back today with more questions...this is so exciting !!

Mellissa

Allen said:
Mellisa, SELECT is a reserved word for queries.
You are likely to run into problems if you don't rename the field.
For this example, I will assume you have renamed it to IsSelected in your
table.

Then:
1. Open your form in design view.

2. Make sure you change both the Control Source of the check box and also
its Name property to IsSelected (or whatever you named your field to.)

3. Set the After Update property for this check box to:
[Event Procedure]

4. Click the Build button beside this property.
Access opens the code window.
Set up the code so it looks like this:

Private Sub IsSelected_AfterUpdate()
If Me.IsSelected = True Then
Me.DateFieldName = Now()
Else
Me.DateFieldName = Null
End If
End Sub

5. Choose Compile in the Debug menu, to ensure Access understands it. Fix
any errors, and repeat until it compiles without error.

Your code is now inside a procedure (i.e. the Sub ... End Sub.)

And here is a list of the field names to avoid:
http://allenbrowne.com/AppIssueBadWord.html
You may wish to refer to that list when creating fields.
[quoted text clipped - 30 lines]
 
M

Mellissa via AccessMonster.com

Hi,

I am now trying to enter a DateModified and TimeModified upon modifying a
record.

In the Form Properties, Events Tab, under AfterUpdate, I have inputted the
following into the module:

Private Sub Form_AfterUpdate()
Me.DateModified = Now()
Me.TimeModified = Now()
End Sub

A Date/Time is successfully entered upon modifying a record however, also
when trying to scroll to the next record I receive the following error
message:

"You cant go to the specified record" ???

Because I am searching a Batch # consisting of many accounts, without the
date/time stamp, I can scroll through all accounts under one batch however,
when inputting the date/time stamp, I cannot scroll.

Am I doing something wrong?

Thanks a bunch ;)
Mellissa
Hi Allen,

Thank you sooooo much. It worked beautifully ;)

I am sure I will be back today with more questions...this is so exciting !!

Mellissa
Mellisa, SELECT is a reserved word for queries.
You are likely to run into problems if you don't rename the field.
[quoted text clipped - 36 lines]
 
A

Allen Browne

Use Form_BeforeUpate instead of Form_AfterUpdate.

There is no point in dirtying the record immediately *after* it is saved so
it needs saving again, at which point, your code dirties it again so that it
needs saving againg, at which point ...

BTW, one field can handle both the date and time.

(In general, Mellissa, it's best to start a new thread for a new question.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Mellissa via AccessMonster.com said:
Hi,

I am now trying to enter a DateModified and TimeModified upon modifying a
record.

In the Form Properties, Events Tab, under AfterUpdate, I have inputted the
following into the module:

Private Sub Form_AfterUpdate()
Me.DateModified = Now()
Me.TimeModified = Now()
End Sub

A Date/Time is successfully entered upon modifying a record however, also
when trying to scroll to the next record I receive the following error
message:

"You cant go to the specified record" ???

Because I am searching a Batch # consisting of many accounts, without the
date/time stamp, I can scroll through all accounts under one batch
however,
when inputting the date/time stamp, I cannot scroll.

Am I doing something wrong?

Thanks a bunch ;)
Mellissa
Hi Allen,

Thank you sooooo much. It worked beautifully ;)

I am sure I will be back today with more questions...this is so exciting
!!

Mellissa
Mellisa, SELECT is a reserved word for queries.
You are likely to run into problems if you don't rename the field.
[quoted text clipped - 36 lines]
 

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