Results 1 to 9 of 9
  1. #1
    Ashfaque is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2021
    Posts
    31

    Compile error User-defined type not defined

    Hi,

    During process of connecting tables from SQL Server which normally takes few seconds(let us say around 30 seconds) I planned to add a progress bar on my main login form. I have downloaded a bunch of lengthy code that stored in a module.

    Moreover,below code placed onclick btn of login form


    Code:
    Private Sub cmdDWood_Click()
    
    On Error GoTo Err_cmdDWood_Click
    
    Const DELAY As Single = 0.1 ' Progress Bar
    Dim intCnt As Integer
    Dim sngTimer As Single
    Dim cProg As New ClsLblProgress
    
    With cProg
    
        .Initialize lblback, lblfront, lblcaption
        .Max = 50
        
    End With
    
    For intCnt = 1 To 50
        sngTimer = Timer
            Do While Timer < sngTimer + DELAY
        DoEvents
        Loop
        cProg.Increment
    Next intCnt
    further code is here...



    While compiling the code it is produced compile error User-defined type not defined on following line before I go ahead...

    Dim cProg As New ClsLblProgress

    Can someone please advise?

  2. #2
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,388
    The code that you downloaded; it might need to be stored in a CLASS module named ClsLblProgress.

  3. #3
    Ashfaque is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2021
    Posts
    31
    Yes, I already saved in a CLASS module called clsLblProg This is mentioned at below link

    https://stackoverflow.com/questions/11956834/progress-bar-in-ms-access/28244159#28244159?newreg=2c03585af2ea4eae99f76c4ec 726af54

  4. #4
    Ashfaque is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2021
    Posts
    31
    I have also attached my Lib pics to let you know which lib files are selected at present.

    Click image for larger version. 

Name:	My Libs.jpg 
Views:	24 
Size:	69.5 KB 
ID:	44444

  5. #5
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,388
    Dim cProg as New clsLblProgress should be
    Dim cProg as New clsLblProg

  6. #6
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,001
    I'd be absolutely amazed if you needed all those references, in fact I'm pretty stunned that some of them aren't conflicting with each other.

    DAO 3.6 was depreciated a fairly long time ago, and replaced with MS Office x.(version depend on your office version) Access Database engine objects.
    ActiveX Data Objects 2.5 has at least 4 newer versions (6.1 being the last I can see)
    ADO Ext 2.8 if you need it replaced by ADO ext 6.0

    If you port this to a different PC or another user you almost certainly will run into issue with references being incorrect, or missing.
    Learn how to use late binding.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  7. #7
    Ashfaque is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2021
    Posts
    31
    Quote Originally Posted by davegri View Post
    Dim cProg as New clsLblProgress should be
    Dim cProg as New clsLblProg
    OMG !!! a smallest thing makes you stuck......I really appreciate your timely help...it runs smoothly now.....

  8. #8
    Ashfaque is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2021
    Posts
    31
    Quote Originally Posted by Minty View Post
    I'd be absolutely amazed if you needed all those references, in fact I'm pretty stunned that some of them aren't conflicting with each other.

    DAO 3.6 was depreciated a fairly long time ago, and replaced with MS Office x.(version depend on your office version) Access Database engine objects.
    ActiveX Data Objects 2.5 has at least 4 newer versions (6.1 being the last I can see)
    ADO Ext 2.8 if you need it replaced by ADO ext 6.0

    If you port this to a different PC or another user you almost certainly will run into issue with references being incorrect, or missing.
    Learn how to use late binding.
    Thanks Minty,

    I am not fair enough to know which lib files are to keep and which one to remove. I have been using these since long. And you are correct...this gives me always error when I deploy my FE to end user. This way I have personlly to visit him and set his lib files as per his office installment. I am looking for such code that provide me auto-selection of lib ref files. I will search for late binding although I dont have idea abt it.

    But one question, I have used record set DAO in all my code. If I remove DAO ref, wouldn't be a problem to run my code smoothly?


    Regards,

  9. #9
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,001
    Quote Originally Posted by Ashfaque View Post
    But one question, I have used record set DAO in all my code. If I remove DAO ref, wouldn't be a problem to run my code smoothly?
    Some of this will depend on what version of office your end users have.

    Have a read here about the DAO reference. https://social.msdn.microsoft.com/Fo...ss-2010-64-bit

    Late binding - read here https://www.granite.ab.ca/access/latebinding.htm
    Personally I would slowly remove those references one at a time and keep compiling your code, until it won't compile.
    That will identify which references you need, but switching out to late binding will remove the issue from your end users.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 10-16-2017, 09:09 AM
  2. DAO ERROR - User Defined type not defined
    By adamtate94 in forum Programming
    Replies: 2
    Last Post: 09-08-2016, 05:42 AM
  3. Replies: 3
    Last Post: 11-12-2013, 04:13 PM
  4. Replies: 1
    Last Post: 12-14-2012, 12:32 AM
  5. Replies: 4
    Last Post: 06-08-2012, 09:08 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums