Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Expression "On Load" Error When Opening a Form.. 1

Status
Not open for further replies.

mmignot

Programmer
Jul 16, 2001
44
US
Hi,

I'm trying to open a form I created, but I get the the following error message:

The expression On Load you entered as the event property setting produced the following error: User-defined type not defined.

* The expression may not result in the name of a macro,
the name of a user-defined function, or [Event Procedure]
* There may have been an error evaluating the function,
event, or macro.

The following is the customized code I added:

Private Sub Form_Load()

Set dbAP = CurrentDb()

'Use the following line to connect to an Access database:
Set recInvFileNames=
(dbAP.OpenRecordset"qryInvoiceFileNames")

recInvFileNames.MoveLast
intLastRecord = recInvFileNames.RecordCount
recInvFileNames.MoveFirst
Load_Controls
Get_InvoiceNbrs

Even when I comment the code ther error still occurs. The only way I can get rid of it is to delete all of the code.

Is there anyone out there that can help?

Thanks in advance. :)
 
Just a wild guess: When you look at the Event Properties tab in your form design view, what does it say in the On Load box? It should say [Event Procedure]
 
You do not have to write

currentdb()

just currentdb without the prenthesis.

Try it let me know if it works.
 
ZevW...

I tried your suggestion (removed "()" from "CurrentDb"), but I'm still getting the error... don't know what to do about this...

MM :)
 
TempClerk...

[Event Procedure] is specified in the "On Load" box....

Heeeelp!!!!!
 
I can't believe people missed this one. C'mon guys! :)

The following code seems to be a problem...

Set recInvFileNames= dbAP.OpenRecordset"qryInvoiceFileNames")

To correct this, try...

Set recInvFileNames = dbAP.OpenRecordset("qryInvoiceFileNames")

The problem was the placement of the parenthesis. Did I miss anything else?

Gary
gwinn7
 
Gary...

I must have did something when I copied the code here. It is coded correctly in the procedure:

Set recInvFileNames = dbAP.OpenRecordset ("qryInvoiceFileNames")

This is a tough one...

MM :)
 
Just a thought,

What are "Load_Controls" and "Get_InvoiceNbrs"? Are they functions defined elsewhere in your form code. Are they public functions in a module?

Sounds like your form cannot find those functions.
Maq B-)
<insert witty signature here>
 
Okay, here is the deal... I tried to compile my code and I received the following error:

Compile error:
User-defined type not defined

The debugger pointed to the following statement:

Dim dbAP As Database

It appears that the object &quot;Database&quot; is not being recognized and I don't know why. Does anyone have any ideas??

MM :)
 
you need to select the:
&quot;Microsoft DAO 3.6 Object Library&quot;

in the refences of the VB editor.

To do that select tools-references from the menu.

HTH
Alcar
 
Alcar...

Thanks, that was the problem. I realized it while doing some more research. App is working fine now. Thanks to all who made suggestions.

MM :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top