Form Access run time error 3075

curtyrut

Registered User.
Local time
Yesterday, 19:48
Joined
Dec 23, 2015
Messages
23
Hello, I received the following error when attempting to have the form populate only data created by users is a specific group. Below is my coding for your review. Your help is greatly appreciated and if my request is a bit unorthodox, this is my first post. Thanks again for patience and continued support:

Private Sub Form_Load()
Dim User As String
Dim mylogin As String
Dim Task As String

User = Environ("UserName")
mylogin = DLookup("HRELT", "tblUser", "UserLogin = '" & User & "'")
Task = "Select * from tblFieldsNames Where (Hiring_Owner = " & mylogin & ")"
Me.RecordSource = Task

The debugger highlighted the me.recordsource.
 
My suggestion is to add this line of code . . .
Code:
Task = "Select * from tblFieldsNames Where (Hiring_Owner = " & mylogin & ")"
[COLOR="Blue"]debug.print Task[/COLOR]
Me.RecordSource = Task
. . . which will print your SQL to the immediate pane. Then, create a new query in the design grid, switch to SQL view, and paste this query text into the new query and run it. This is the way to test your own SQL.
Hope it helps,
 
If Hiring_Owner is text, then mylogin has to be surrounded by '.
Code:
Task = "Select * from tblFieldsNames Where (Hiring_Owner = [B][COLOR=Red]'[/COLOR][/B]" & mylogin & "[B][COLOR=Red]'[/COLOR][/B])"
 
JHB, thank you for resolving my problem, your solution worked!
 
You're welcome, good luck. :)
 

Users who are viewing this thread

Back
Top Bottom