mdnuts
Registered User.
- Local time
- Today, 08:11
- Joined
- May 28, 2014
- Messages
- 128
I currently have this set as the forms default recordsource (which works just fine):
and i have this vba to dynamically switch around that email address.
If I msgbox the sSQL - it shows identical to the default recordsource but I get the error:
The error message I get is:
Code:
SELECT TOP 5 tblUsers_Phone_Book.EMAIL_ADDRESS, weightedDL('me@mine.com',[EMAIL_ADDRESS]) AS Expr1
Code:
Private Sub Form_Load()
Dim intPos As Integer
Dim strControlName As String
Dim strValue As String
Dim sSQL As String
If Len(Me.OpenArgs) > 0 Then
' Position of the pipe
intPos = InStr(Me.OpenArgs, "|")
If intPos > 0 Then
' Retrieve Control Name from the first part of the string
strControlName = Left$(Me.OpenArgs, intPos - 1)
' Retrieve Value to Assign from the end of the string
strValue = Mid$(Me.OpenArgs, intPos + 1)
' Assign the value to the control
End If
End If
sSQL = "SELECT TOP 5 tblPriv_Users_Phone_Book.EMAIL_ADDRESS, weightedDL('" & strValue & "',[EMAIL_ADDRESS]) AS Expr1"
With Me.Form
.RecordSource = sSQL
.Refresh
End With
End Sub
The error message I get is:
Any ideas? I've banged around it for a bit now and just can't see it. I tried coping the exact working default sql into the vba and get the same result.Run-Time error '2580'
The record source 'SELECT TOP 5 tblUsers_Phone_Book.EMAIL_ADDRESS, weightedDL('me@mine.com',[EMAIL_ADDRESS]) AS Expr1' specified on this form or report does not exist.