Compile Error: User Defined type not defined (1 Viewer)

Gr3g0ry

Registered User.
Local time
Today, 03:40
Joined
Oct 12, 2017
Messages
163
im helping a friend with a project, he copied my login screen, users table and password query. it works fine on my pc, and fine on 3 other mates' computers but for this fourth friend, he is getting errors.

i think ive tried all the suggestions found in forums: but to no avail, including making sure the Data Access Objects library (DAO) is checked in the Tools. below is an image of my code, and highlighted is the line of code giving me the error. any help would be appreciated

1675703871071.png
 

jdraw

Super Moderator
Staff member
Local time
Today, 06:40
Joined
Jan 23, 2006
Messages
15,379
Add a second line to your module, at the top
Option Explicit

Take a screen capture of your References. See if any show as Missing.
 

Gr3g0ry

Registered User.
Local time
Today, 03:40
Joined
Oct 12, 2017
Messages
163
Add a second line to your module, at the top
Option Explicit

Take a screen capture of your References. See if any show as Missing.


below is the error im getting after including Option Explicit.
1675705035077.png


below are my references
1675706079531.png
 

Attachments

  • 1675705074918.png
    1675705074918.png
    95.5 KB · Views: 70

jdraw

Super Moderator
Staff member
Local time
Today, 06:40
Joined
Jan 23, 2006
Messages
15,379
Option Explicit is second line at the top of the MODULE, not procedure.

Top 2 lines in every module
Option Compare Database
Option Explicit


What version of Access are you using?

Seems there may be a reference for Access Database Engine Object Library???
 

ebs17

Well-known member
Local time
Today, 12:40
Joined
Feb 7, 2020
Messages
1,948
In newer versions of Access, for DAO you should rather use the reference to Microsoft Office XX.0 Access Database Engine Object and remove the reference to DAO3.6.
 

Gr3g0ry

Registered User.
Local time
Today, 03:40
Joined
Oct 12, 2017
Messages
163
Option Explicit is second line at the top of the MODULE, not procedure.

Top 2 lines in every module
Option Compare Database
Option Explicit


What version of Access are you using?

Seems there may be a reference for Access Database Engine Object Library???
sorted out the top 2 lines ... now i understand
using Office 2013
 

Gr3g0ry

Registered User.
Local time
Today, 03:40
Joined
Oct 12, 2017
Messages
163
sigh ... can i post the access file, specify the form im having issue with and someone help ??
 

Gr3g0ry

Registered User.
Local time
Today, 03:40
Joined
Oct 12, 2017
Messages
163
In newer versions of Access, for DAO you should rather use the reference to Microsoft Office XX.0 Access Database Engine Object and remove the reference to DAO3.6.
tried this also ... trying suggestions on different versions on different pcs ... getting different errors now
Error 1:
1675709040003.png

and Error 2:
1675709063332.png

i know the names of my menu forms are not Main and Main2 but instead, Menu and Menu2
 

ebs17

Well-known member
Local time
Today, 12:40
Joined
Feb 7, 2020
Messages
1,948
tried this also ... trying suggestions on different versions on different pcs ... getting different errors now
That's good news. Fixing one error clears the way for the next ones to show up.
Believing that you only have one error is sometimes a sign of being overly optimistic.
 

Gr3g0ry

Registered User.
Local time
Today, 03:40
Joined
Oct 12, 2017
Messages
163
That's good news. Fixing one error clears the way for the next ones to show up.
Believing that you only have one error is sometimes a sign of being overly optimistic.
yeah i kno ... one error at a time ... if you look above i posted the entire access file im working with.
 

Gasman

Enthusiastic Amateur
Local time
Today, 11:40
Joined
Sep 21, 2011
Messages
14,311
yeah i kno ... one error at a time ... if you look above i posted the entire access file im working with.
If that was meant to be post #8, nothing attached?
 

Gr3g0ry

Registered User.
Local time
Today, 03:40
Joined
Oct 12, 2017
Messages
163
Code:
Private Sub loginbtn_Click()

Dim dbs As Database
Dim rstUserPwrd As Recordset
Dim bfoundMatch As Boolean
Dim utype As String

Set dbs = CurrentDb

Set rstUserPwrd = dbs.OpenRecordset("qryUserPwd")
bfoundMatch = False

If rstUserPwrd.RecordCount > 0 Then
    rstUserPwrd.MoveFirst

    ' check for matching records
    Do While rstUserPwrd.EOF = False
    If rstUserPwrd![UserName] = Form_Login1.txtusername.Value And rstUserPwrd![Password] = Form_Login1.txtpassword.Value Then
    
        bfoundMatch = True
        utype = rstUserPwrd![level].Value
        Exit Do
        
    End If
        rstUserPwrd.MoveNext
    Loop
    
End If

If bfoundMatch = True Then
'Open the next form here and close this one
DoCmd.Close acForm, Me.Name
    
    If utype = "Admin" Then
    DoCmd.OpenForm "Menu"
    Else
    DoCmd.OpenForm "Menu2"
    End If
Else

MsgBox "Incorrect Username and or Password"

End If

End Sub
 

Gasman

Enthusiastic Amateur
Local time
Today, 11:40
Joined
Sep 21, 2011
Messages
14,311
Perhaps open the other form before closing the one running the code?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 18:40
Joined
May 7, 2009
Messages
19,245
you add Reference (in VBA) to:

Microsoft Office 15.0 Access database engine Object

After you have set the reference, change your code from:

Dim dbs As Database
Dim rstUserPwrd As Recordset

TO:

Dim dbs As DAO.Database
Dim rstUserPwrd As DAO.Recordset
 

Users who are viewing this thread

Top Bottom