Escaping ‘ in Access SQL
The “Replace” function should do the trick. Based on your code above: DLookup(“island”, “villages”, “village=”” & Replace(txtVillage, “””, “””) & “‘”)
The “Replace” function should do the trick. Based on your code above: DLookup(“island”, “villages”, “village=”” & Replace(txtVillage, “””, “””) & “‘”)
It is possible to do a little with VBA. For example, here is a start on creating script for a database with local tables. Dim db As Database Dim tdf As TableDef Dim fld As DAO.Field Dim ndx As DAO.Index Dim strSQL As String Dim strFlds As String Dim strCn As String Dim fs, f … Read more
There’s nothing to get the current function name, but you can build a fairly lightweight tracing system using the fact that VBA object lifetimes are deterministic. For example, you can have a class called ‘Tracer’ with this code: Private proc_ As String Public Sub init(proc As String) proc_ = proc End Sub Private Sub Class_Terminate() … Read more
To get more information about the cause of an “ODBC–call failed.” error we can loop through the DBEngine.Errors collection and see if there are other messages that might be a bit more descriptive. For example, with the code qdf.Connect = strConnectionString qdf.SQL = ” EXEC [dbo].[SAMPLE_TEST]” qdf.ReturnsRecords = True On Error GoTo oops Set rst … Read more
Here is a way to catch most outcomes of interacting with the dialog; Dim value As String value = InputBox(“Please enter a #”, “Determine Limit”, 10000) If (StrPtr(value) = 0) Then MsgBox “You pressed cancel or [X]” ElseIf (value = “”) Then MsgBox “You did not enter anything” ElseIf (Val(value) = 0 And value <> … Read more
In order to get rid of the EXCEPT you could combine the conditions and negate the second one: SELECT DISTINCT P.Name, T.Training FROM Prof AS P, Training_done AS TC, Trainings AS T WHERE ((P.Name Like ‘*’ & NameProf & ‘*’) AND (P.Primary_Area = T.Cod_Area)) AND NOT ((P.Name Like ‘*’ & NameProf & ‘*’) AND (P.Cod_Prof … Read more
I think you should avoid this path at all cost, and try and persuade management into redevelopment. It’s a bitter pill to swallow, but this is going to need to be redeveloped sooner or later, and you are just saving them time and money.
You can use the hidden system table MSysObjects to check if a table exists: If Not IsNull(DlookUp(“Name”,”MSysObjects”,”Name=”TableName””)) Then ‘Table Exists However, I agree that it is a very bad idea to create a new table every day. EDIT: I should add that tables have a type 1, 4 or 6 and it is possible for … Read more
Nobody has actually given you any code examples here in the answer or even cited an example (the Access help files do include examples, though). The key issue to keep in mind is that in Jet/ACE (Access does not support transactions itself — it depends on whatever database engine you’re using for that) that the … Read more
The decimal data type isn’t supported in the default Jet 4.0 mdb file. You have to use the SQL Server compatibility syntax (ANSI 92) setting to use the decimal data type in the SQL Window. Click on the menu, Tools > Options. Click on the Tables/Query tab. Mark the check box for “This database” in … Read more