Ms Access 2010 There Was An Error Compiling This Function
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site there was an error compiling this function the visual basic module About Us Learn more about Stack Overflow the company Business Learn more
Access Compile Error In Query Expression
about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss
Access 2016 Compile Error In Query Expression
Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Access database functions
The Visual Basic Module Contains A Syntax Error
up vote 0 down vote favorite I created a database at work on Access 2010 with queries using the left(),right() and mid() functions. I then copied the database over to my pc at home, but now these functions does not want to work on this database. My pc at home also has Access 2010. Everytime i try to run a query i get the following microsoft access compile error can't find project or library message, There was an error compiling this function. Visual basic contains a syntax error. Check the code and then compile it again. I created a new DB on my pc at home to test the functions and had no problems. I also noticed that on my pc at home the heading reads Database1 : Database(Access 2007) - Microsoft Access while at work it says Database1 : Database(Access 2007 - 2010) - Microsoft Access. Both PCs have Windows 7 Professional and my home PC is about 1 year old and my pc at work about 3 months. I also updated/repaired my Access at home, but the DB still does not want to work. How can i fix this problem? I have a simple table call it Table1 with an id column and a column named Name, id Name 1 Jason 2 Casey 3 Shasha Now if i want to use the left() function in an Access query , i get the error message: There was an error compiling this function. Visual basic contains a syntax error. Check the code and then compile it again. Query: Select Left([Name],2) As Short_name From Table1 ms-access share|
Access 2010 Page 1 of 1 New Topic/Question Reply 6 Replies - 10047 Views - Last Post: 28 December 2012 - 03:39 access 2010 the visual basic module contains a syntax error PM #1 VIPER5646 D.I.C Head Reputation: 1 Posts: 92 Joined: compile error in query expression now 01-March 09 Compile error when running a Function in Access 2010 Posted 28 December 2012 - 10:09 access 2013 compile error AM The following function works well in VS2010. Then I rewrote it in access but every time I call it I get a Compile error in the first http://stackoverflow.com/questions/27328974/access-database-functions line. Your help would be appreciated. Public Function GetBusinessDayDifference(ByVal date1 As Date, ByVal date2 As Date) As Integer Dim startDate As Date = If(date1 < date2, date1, date2) Dim endDate As Date = If(date1 > date2, date1, date2) Dim difference As TimeSpan = endDate - startDate Dim totalDays As Integer = difference.Days Dim weeks As Integer http://www.dreamincode.net/forums/topic/305059-compile-error-when-running-a-function-in-access-2010/ = totalDays \ 7 Dim days As Integer = totalDays Mod 7 Dim businessDays As Integer = weeks * 5 For offset As Integer = 1 To days Select Case startDate.AddDays(offset).DayOfWeek Case DayOfWeek.Monday, _ DayOfWeek.Tuesday, _ DayOfWeek.Wednesday, _ DayOfWeek.Thursday, _ DayOfWeek.Friday businessDays += 1 End Select Next Return businessDays End Function This is the query I'm Using to call the function SELECT TBDfilter_qry.ID, TBDfilter_qry.Date, TBDfilter_qry.Order_Entry, TBDfilter_qry.Adress, TBDfilter_qry.City, TBDfilter_qry.Civic, TBDfilter_qry.tobeMeasured, TBDfilter_qry.tobeDesign, TBDfilter_qry.DEsign AS Design, TBDfilter_qry.Hold, TBDfilter_qry.Closing AS Closing, Status_Diff_tbl.Design, GetBusinessDayDifference(Now(),[TBDfilter_qry].[tobeDesign]) AS Dif FROM TBDfilter_qry, Status_Diff_tbl; This post has been edited by VIPER5646: 28 December 2012 - 10:19 AM Is This A Good Question/Topic? 0 Back to top MultiQuote Quote + Reply Replies To: Compile error when running a Function in Access 2010 #2 macosxnerd101 Games, Graphs, and Auctions Reputation: 12002 Posts: 44,829 Joined: 27-December 08 Re: Compile error when running a Function in Access 2010 Posted 28 December 2012 - 10:28 AM Please post your specific errors. Was This Post Helpful? 0 Back to top MultiQ
for Help Receive Real-Time Help Create a Freelance Project Hire for a Full Time Job Ways to Get Help Ask a Question Ask for Help Receive Real-Time Help Create a Freelance Project Hire for a Full Time Job Ways to Get Help Expand Search Submit Close Search Login Join Today Products BackProducts Gigs Live Careers Vendor Services Groups Website https://www.experts-exchange.com/questions/20327422/Error-Compiling-a-function.html Testing Store Headlines Experts Exchange > Questions > Error Compiling a function Want to Advertise Here? Solved Error Compiling a function Posted on 2002-07-24 MS Access 1 Verified Solution 8 Comments 1,278 Views Last Modified: 2012-06-21 Hello experts, I copied a startup() function into the database that I'm Working on right now. This function gets the user's NT userID and other misc. info and then uses it to do some security. When I imported the function and tried to test it I got the following error: "There was compile error an error compiling a function" The Visual Basic module contains a syntax error - check the code and then recompile it" The function runs fine on the database that I imported it from. Below is the VB for the function and I put the line that the compile bites on in quotes. Option Compare Database Option Explicit Declare Function API_GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long Declare Function GetComputerName& Lib "KERNEL32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) Global gbUpdateUser the visual basic As Boolean Global gsSQL As String Dim msUserID As String Dim msSQL As String Dim mRS As Recordset "Dim mDB As Database" Public Function Startup() As Boolean gbUpdateUser = False msUserID = GetUserName() Set mDB = CurrentDb CaptureLogin msSQL = "SELECT * FROM tblUsers WHERE tblUsers.NTID= '" & msUserID & " ';" Set mRS = mDB.OpenRecordset(msSQL, dbOpenSnapshot) With mRS If Not .EOF Then .MoveLast If .RecordCount > 0 _ And !admin = True Then gbUpdateUser = True End If End If .Close End With mDB.Close Set mRS = Nothing Set mDB = Nothing MsgBox "Welcome to the Problem Report Database", vbInformation + vbOKOnly, "Welcome" End Function Does anyone have any idea why this would happen on the new database and not on the one I copied it from. I'm using Access2000 and Windows2000. Thanks very much. P.S I didn't paste in the entire code so if you wonder why something might be missing..... 0 Question by:tdenny Facebook Twitter LinkedIn Go