Lyanne Is it a typo? Quotes are misplaced in your SQL string. Try
Private Sub cmdCreateUserClasses_Click() strSQL = "UPDATE UsersAndUserClasses SET UsersAndUserClasses.AddUserClassSubmit = " & UserClassSubmit _ & " WHERE UsersAndUserClasses.EListItemName = [UsersAndUserClasses].[EListItemParentName]; " UserClassSubmit is outside quotes since it has to be called by the sub. HTH Liveson ----- Original Message ----- From: Lyanne Rheeza Ong To: [email protected] Sent: Wednesday, 05 March, 2008 7:32 PM Subject: [ms_access] error on function - SQL related Hello everyone, i tried the code below and the error undefined UserClassSubmit () [code] Function UserClassSubmit() As String Dim rsCurr As DAO.Recordset Dim strSQL As String strSQL = "SELECT 'AddUserClass,' & Application.ApplicationName" & _ "', ' & Variable.ParentApplicationUserClassName" & _ "FROM Variable, Application " & _ "WHERE Variable.ApplicationUserClassName = '" & Me.cboApplicationName.Value & " ' " & _ "AND Variable.ApplicationUserClassName = Application.ApplicationID" Set rsCurr = CurrentDb.OpenRecordset(strSQL) If rsCurr.BOF = False And rsCurr.EOF = False Then UserClassSubmit = rsCurr.Fields(0) End If rsCurr.Close Set rsCurr = Nothing End Function Private Sub cmdCreateUserClasses_Click() strSQL = "UPDATE UsersAndUserClasses SET UsersAndUserClasses.AddUserClassSubmit = UserClassSubmit() " _ & "WHERE UsersAndUserClasses.EListItemName = [UsersAndUserClasses].[EListItemParentName]; " Debug.Print strSQL CurrentDb.Execute strSQL, dbFailOnError End Sub [/code] Also, can i update more than 1 record in a table using the update statement? please be patient with this newbie. please help! =) thanks, lyanne L y a n n e R h e e z a C. O n g --------------------------------- Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. [Non-text portions of this message have been removed] [Non-text portions of this message have been removed]
