Compile error: user defined type not defined.

Raven90

New member
Local time
Today, 13:56
Joined
Dec 16, 2015
Messages
4
Access 2007
------------
Code
Private Sub btnPost_Click() //This line is highlighted in yellow
Dim strMsgBox As StringForm.Recalc
If txtEnterTotalHours = txtHourTotal Then
Dim strMacroName As String
strMacroName = "mcrPost"
DoCmd.RunMacro strMacroName
Else: MsgBox ("Total Hours Worked must Equal Actual Hours Entered")
End If
End Sub


End Code
----------
Gives error Compile error: User-Defined type not defined.

They try to post hours to an employee and it gives this with the top line highlighted.

I have Microsoft DAO 3.6 Object Library selected under tools --> references for my database.
 
What is that line supposed to do? I'm unfamiliar with it, and you don't appear to use it.
 
Its a button. When they click the button it posts the hours to the corresponding user. I know its not much information, its worked forever and just recently broke. So I don't think its the code per say - maybe something under references in missing.

Correct I don't use it - some other people do and the person/coder who made it is no longer with us.
 
I meant the code in that event doesn't appear to use the line that is highlighted. Try commenting it out and see if everything works.
 
Is "Dim strMsgBox As StringForm.Recalc " supposed to be "Dim strMsgBox As String" ?

VB seems to think 'StringForm.Recalc is a undefined user-defined type.
 
That fixed it - It was the line after the first one though. It was highlighted in blue cursor (i guess yellow is just the button category of where the code lies?). The "Dim strMsgBox As StrinForum.Recalc" - I commented that out and it seems to work now.

Thank you!
 
No problem, and welcome to the site by the way!
 
Glad to hear. The yellow highlight is the line where the code execution broke. In this case, VB tried to initialize the subroutine "btnPost_Click" but it failed (stopped) because you the line of code you commented out was trying to declare a Type that didn't exist.
 
I see - appreciate the help from you all. Just started using access and working with the VB database. New to me!

Thanks all!
 

Users who are viewing this thread

Back
Top Bottom