Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 500419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:05:07+00:00 2026-05-13T06:05:07+00:00

I have an Access application where everytime a user enters the application, it makes

  • 0

I have an Access application where everytime a user enters the application, it makes a temp table for that user called ‘their windows login name’_Temp. In one of my reports I need to query using that table, and I can’t just make a query and set it as the recourdsource of the report, since the name of the table is always different.

What I tried then was to programatically set the recordset of the report by running the query and setting the form’s recordset as the query’s recordset. When I tried this, it kept giving me an error about the query.

I tried to debug, and I found that the string variable isn’t able to contain the whole query at once. When I ran it with break points and added a watch for the string variable, it shows me that it cuts off the query somewhere in the middle.

I’ve experienced this problem before, but that was with an UPDATE query. Then, I just split it into two queries and ran both of them separately. This one is a SELECT query, and there’s no way I can split it. Please help!

Thank you

Heres what I’ve tried doing:

ReturnUserName is a function in a module that returns just the login id of the user

Private Sub Report_Open(Cancel As Integer)

Dim strQuery As String
Dim user As String
user = ReturnUserName

strQuery = "SELECT " & user & "_Temp.EmpNumber, [FName] & ' ' & [LName] AS [Employee Name], " & _
"CourseName, DateCompleted, tblEmp_SuperAdmin.[Cost Centre] " & _
"FROM (tblCourse INNER JOIN (" & user & "_Temp INNER JOIN tblEmpCourses ON " & _
user & "_Temp.EmpNumber = EmpNo) ON tblCourse.CourseID = tblEmpCourses.CourseID) " & _
"INNER JOIN tblEmp_SuperAdmin ON " & user & "_Temp.EmpNumber = tblEmp_SuperAdmin.EmpNumber" & _
"WHERE (((" & user & "_Temp.EmpNumber) = [Forms]![Reports]![txtEmpID].[Text])) " & _
"ORDER BY CourseName;"

Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Dim rsCmd As ADODB.Command
Set rsCmd = New ADODB.Command
rsCmd.ActiveConnection = CurrentProject.Connection

rsCmd.CommandText = strQuery
rs.Open rsCmd
Me.Recordset = rs
rs.Close

End Sub

This what strQuery contains when I add a breakpoint on rsCmd.CommandText = strQuery:

SELECT myusername_Temp.EmpNumber, [FName]
& ‘ ‘ & [LName] AS [Employee Name],
CourseName, DateCompleted,

tblEmp_SuperAdmin.[Cost Centre] FROM

(tblCourse INNER JOIN (myusername_Temp
INNER JOIN tblEmpCourses ON

myusername_Temp.EmpNumber = EmpNo) ON
tblCourse.CourseID=

(It’s all one line, but I’ve written it like this because the underscores italicize the text)

And the error I get says Run Time Error: Join not Supported.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T06:05:07+00:00Added an answer on May 13, 2026 at 6:05 am

    Not quite what I was hoping for, but guessing, for:

    strQuery = "long query goes here"
    

    Try:

    strQuery = "some long query goes here "
    strQuery = strQuery  & "more query goes here "
    

    BASED ON NEW INFORMATION:

    strQuery = "SELECT " & user & "_Temp.EmpNumber, [FName] & ' ' & [LName] AS [Employee Name], " & _
    "CourseName, DateCompleted, tblEmp_SuperAdmin.[Cost Centre] " & _
    "FROM (tblCourse " & _
    "INNER JOIN tblEmpCourses ON tblCourse.CourseID = tblEmpCourses.CourseID) " & _
    "INNER JOIN (Temp INNER JOIN tblEmp_SuperAdmin  " & _
    "ON  Temp.EmpNumber = tblEmp_SuperAdmin.EmpNumber)  " & _
    "ON Temp.EmpNumber = tblEmpCourses.EmpNo  " & _
    "WHERE " & user & "_Temp.EmpNumber =  " & [Forms]![Reports]![txtEmpID] & _
    " ORDER BY CourseName;"
    

    Note that in VBA:

    & [Forms]![Reports]![txtEmpID].[Text] &
    

    That is, the reference to the form must go outside the quotes so you get the value.

    NEW INFORMATION #2

    Your best bet would be to add these tables to the Access query design window and create the joins that you want, then switch to SQL view and use the string generated for you. I do not believe that the string is too long, only that the SQL is incorrect. The SQL I posted above should work, but it may not be what you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.