Get Name of Current VBA Function

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

Trouble with InputBoxes

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

VBA – Run Time Error 3271 using DAO object

You’re facing a limitation of Access SQL text parameters. They can not accommodate string values longer than 255 characters. Here is a simple example which demonstrates the problem. Dim db As DAO.Database Dim qdf As DAO.QueryDef Dim strUpdate As String Dim strLongString As String strLongString = String(300, “x”) strUpdate = “UPDATE tblFoo SET memo_field = … Read more

How to use cross join in access?

I’m not sure about what do want to accomplish, but the syntax for a full cartesian product(cross join) is select * from table1, table2 If you don’t want to cross everything but only some columns, something like SELECT * FROM (select id from details) b, (select detail from details) c ; should work: id detail … Read more