Compile error faced

G

geek

i've come across the error message stating "Compile Error. User defined type
not defined." how do i go about solving this problem? the codes are as below:

for your information, i'm using office 2003.

thanks!

Option Compare Database
Option Explicit

Function M_Date_check()
Dim db As Database
Dim ds As Recordset
Dim Mysql As String
Dim Current_Y As Integer, Current_M As Integer
Dim I As Integer

Set db = CurrentDb

Mysql = "Year_Month_Data_M"
Set ds = db.OpenRecordset(Mysql, dbOpenDynaset)
Current_Y = Val(ds![Year])
Current_M = Val(ds![Month])
ds.Close


End Function
 
A

Allen Browne

Which line gives the error?

Chances are you could solve this by opening a code window, and choosing
References on the Tools menu. Then check the box beside:
Microsoft DAO 3.6 library.

You will then get another error on the 3rd line unless you use:
Dim ds As DAO.Recordset

More info on references:
http://allenbrowne.com/ser-38.html
 
G

geek

thanks! i've solved my problems!

Allen Browne said:
Which line gives the error?

Chances are you could solve this by opening a code window, and choosing
References on the Tools menu. Then check the box beside:
Microsoft DAO 3.6 library.

You will then get another error on the 3rd line unless you use:
Dim ds As DAO.Recordset

More info on references:
http://allenbrowne.com/ser-38.html

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

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

geek said:
i've come across the error message stating "Compile Error. User defined
type
not defined." how do i go about solving this problem? the codes are as
below:

for your information, i'm using office 2003.

thanks!

Option Compare Database
Option Explicit

Function M_Date_check()
Dim db As Database
Dim ds As Recordset
Dim Mysql As String
Dim Current_Y As Integer, Current_M As Integer
Dim I As Integer

Set db = CurrentDb

Mysql = "Year_Month_Data_M"
Set ds = db.OpenRecordset(Mysql, dbOpenDynaset)
Current_Y = Val(ds![Year])
Current_M = Val(ds![Month])
ds.Close


End Function
 

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