error message on open form

R

Ryis

Hello, I have a click event that references a function in a module, but
everytime i use it i get the following error

This error occurs when an event has failed to run because Microsoft Office
Access cannot evaluate the location of the logic for the event. For example,
if the OnOpen property of a form is set to =[Field], this error occurs
because Access expects a macro or event name to run when the event is fired.

Below is the code

Function TRAININGRECORD()

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "TRAINING FORM"
DoCmd.OpenForm stDocName, , , stLinkCriteria


End Function

any help would be appreciated on this

Thanks

Ryan
 
C

Clifford Bass

Hi Ryan,

It is a little unclear to me exactly what your goal is. Are you trying
to set it up to open TRAINING FORM when some other form opens? If so, just
set the other form's On Open event property to:

=TRAININGRECORD()

Clifford Bass
 
R

Ryis

Hi Clifford,

Sorry, I have the event set to =TRAININGFORM() already but the error still
comes up. When I create a button to open the form it works fine....not sure
why the link from the datasheet won't work. I have many others set up
already..and they work fine...its just this one

Thanks

Ryan

Clifford Bass said:
Hi Ryan,

It is a little unclear to me exactly what your goal is. Are you trying
to set it up to open TRAINING FORM when some other form opens? If so, just
set the other form's On Open event property to:

=TRAININGRECORD()

Clifford Bass

Ryis said:
Hello, I have a click event that references a function in a module, but
everytime i use it i get the following error

This error occurs when an event has failed to run because Microsoft Office
Access cannot evaluate the location of the logic for the event. For example,
if the OnOpen property of a form is set to =[Field], this error occurs
because Access expects a macro or event name to run when the event is fired.

Below is the code

Function TRAININGRECORD()

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "TRAINING FORM"
DoCmd.OpenForm stDocName, , , stLinkCriteria


End Function

any help would be appreciated on this

Thanks

Ryan
 
C

Clifford Bass

Hi Ryan,

So where is the TRAININGFORM() function located? In the new form's
module? In a general module? Some other forms' module? Any chance there is
more than one copy of the function in your modules, causing Access to be
confused? You could try changing the name, see if that makes a difference.

Clifford Bass
 
R

Ryis

Hi Clifford,

General Module, I changed the name to TrainingNew() and tried again, but
keep getting the same error. I looked through all the modules to make sure
there was no duplicates. What I have is a datasheet in a subform that is
based on a query, i have added a uncontrolled field which defaults to click
here, once the user clicks it is supposed to open up the training form and
create a record.

not sure whats going on??

Ryan
 
C

Clifford Bass

Hi Ryan,

How about changing the On Click event property to an Event Procedure
and just calling the TrainingNew function from within that event procedure?
Or, directly placing the code within the event procedure?

Clifford Bass
 

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