Form Access run time error 3075 (1 Viewer)

curtyrut

Registered User.
Local time
Yesterday, 23:51
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.
 

MarkK

bit cruncher
Local time
Yesterday, 20:51
Joined
Mar 17, 2004
Messages
8,179
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,
 

JHB

Have been here a while
Local time
Today, 05:51
Joined
Jun 17, 2012
Messages
7,732
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])"
 

curtyrut

Registered User.
Local time
Yesterday, 23:51
Joined
Dec 23, 2015
Messages
23
JHB, thank you for resolving my problem, your solution worked!
 

JHB

Have been here a while
Local time
Today, 05:51
Joined
Jun 17, 2012
Messages
7,732
You're welcome, good luck. :)
 

Users who are viewing this thread

Top Bottom