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 dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compiler error! user-defined type not defined 1

Status
Not open for further replies.

associates

IS-IT--Management
Aug 2, 2005
59
AU
Hi,

I have got a compiler error that says user-defined type not defined. What happens is i've got a code from a website that shows how to create a calendar and when user
choose a date from the calendar window, it would appear on the textbox automatically. That's cool. However, i created a new database for testing purpose only and copy and paste the code on to it. It worked with no problem. The problem occured after having put the code onto the real database that i want it to be, it doesn't work. It says compiler error. User-defined type not defined. It's actually highlighting the line where it's got
"Dim db As DAO.Database".

Here is the code:

Private Function GetProperty(ByVal strPropName As String, ByRef strPropValue As Variant) As Boolean

Const cProcedureName As String = "GetProperty"
On Error GoTo Err_Handler
Dim db As DAO.Database

Set db = CurrentDb
strPropValue = db.Properties(strPropName)
GetProperty = True

Exit_Sub:
On Error GoTo 0
Set db = Nothing
Exit Function

Sorry for asking this silly question. I realised that there is no such thing as DAO.
The strange thing is that why it works on the dummy database but not the other one. I have made sure that i copied and pasted exactly everything. Correct me if i'm wrong.

I'd be grateful if anyone might be able to help me solve this.

Thank you in advance
 
You need a reference to the DAO 3.6 library in your application. (In module design view, Tools>References)
 
How are ya associates . . .

[blue]lupins46[/blue] radar is on target!

The code requires [purple]Microsoft DAO 3.6 Object Library[/purple] to run. To [blue]check/install[/blue] the library, in any code window click [blue]Tools[/blue] - [blue]References...[/blue] In the listing find the library and [blue]make sure its checked.[/blue] Then using the up arrow, [purple]push it up as high in priority as it will go[/purple]. Click OK.

Calvin.gif
See Ya! . . . . . .
 
Hi, many thanks to you both Lupins46 and TheAceMan1 for your help. It works now. I just did as instructed by you guys. Thanks for that.

However, may i ask another question though?

This is what i wanted to do i.e. i have a textbox called TB_DateFrom in a form. It'd pop up a small dialog window containing calendar of the year when double-clicking on it. And when a user clicks or select a particular date from the calendar, that date would appear on the textbox TB_DateFrom straight after the pop-up window has disappeared. BTW, I have a listbox listing out all the records. My question is if it's possible to perform requery and update the listbox based on the value of TB_DateFrom. Currently, i am using the event called on_exit(). It works but i guess it'd be better if it can do updating the listbox without calling the on_exit event.

Thank you in advance and look forward to hearing from you
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top