Im sorry i know this question is similar to some others but im still confused. My current form displays a persons department number, im trying to find that departments name by searching a department table using an sql statement. But i get an error saying data method or member not found. What am i doing wrong? My code is the following:
Dim strSELECT As String
Dim strFROM As String
Dim strWHERE As String
Dim sql As String
Even though the SQL returns one column and one row it is still considered a recordset. Also, the RunSQL is typically used with action queries (UPDATE, APPEND, DELETE) you are using it with a SELECT query.
I believe you should change you approach. You can either use the DLookup function to return the value you want, or you need to use a ADO or DAO recordset object to do it. In your case I would recommend the DLookup. ADO/DAO will require more research and learning.
Sorry another quick question relating to dlookup functions, what is the syntax for making the criteria equal to a variable? I have a variable that gets a code for the original tutor and im trying to find the name relating to that code, but it is not printing anything out, is it something to do with quotation marks?
Dim oldTutName As Variant
oldTutName = DLookup("[TU_FORENAME]", "tblTutor", "[TU_CODE] =" & oldTutCode)