[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Error 3078

Posted on 2006-11-28
13
Medium Priority
?
795 Views
Last Modified: 2008-01-09
What is wrong with this SQL statement:

    strDeptApp = "SELECT tblDepartApplicability.FunctionQuestionRecID, " _
      & "luDepartments.DepartmentName FROM tblDepartApplicability INNER JOIN " _
      & "luDepartments ON tblDepartApplicability.DepartRecID = " _
      & "luDepartments.DepartRecID WHERE tblDepartApplicability.FunctionQuestionRecID = " _
      & [Forms]![frmEditQuestions]![FunctionQuestionRecID] _
      & " ORDER BY tblDepartApplicability.FunctionQuestionRecID, " _
      & "luDepartments.DepartmentName"

I am getting runtime error 3078.

The Microsoft Jeft database engine cannot find the input table or query ".

Thanks for your assistance!
Lena
0
Comment
Question by:LenaWood
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 3
  • +1
13 Comments
 
LVL 66

Expert Comment

by:Jim Horn
ID: 18031705
Post the code that attempts to execute strDeptApp.
0
 
LVL 10

Author Comment

by:LenaWood
ID: 18031727
   Set rsApp = db.OpenRecordset(sqlDeptApp)
0
 
LVL 10

Author Comment

by:LenaWood
ID: 18031760
This is the complete code behind the button:

Private Sub cmdAdd_Click()

    Dim db As DAO.Database
    Dim rsApp As DAO.Recordset
    Dim strDeptApp As String
    Dim sqlDeptApp As String
   
    Set db = CurrentDb
   
    strDeptApp = "SELECT tblDepartApplicability.FunctionQuestionRecID, " _
      & "luDepartments.DepartmentName FROM tblDepartApplicability INNER JOIN " _
      & "luDepartments ON tblDepartApplicability.DepartRecID = " _
      & "luDepartments.DepartRecID WHERE tblDepartApplicability.FunctionQuestionRecID = " _
      & [Forms]![frmEditQuestions]![FunctionQuestionRecID] _
      & " ORDER BY tblDepartApplicability.FunctionQuestionRecID, " _
      & "luDepartments.DepartmentName"
   
    Set rsApp = db.OpenRecordset(sqlDeptApp)
   
    Debug.Print rsApp.RecordCount
   
    If Not IsNull(Me.FunctionQuestionRecID) Then
        If Not IsNull(Me.FunctionalAreaID) And Me.FunctionQuestionRecID <> "" Then
            If Not IsNull(Me.FunctionalQuestion) Then
               
                MyTrackChanges "New Question Added", Me.FunctionQuestionRecID, Null, _
                  Null, "A new question has been added." & vbCrLf & vbCrLf _
                  & "Functional Area:  " & Me.FunctionalAreaID.Column(1) & vbCrLf _
                  & "Functional Category:  " & Nz(Me.FunctionalAreaCategoryID.Column(1), Null) & vbCrLf _
                  & "Reference(s):  " & Me.FunctionalReference, True

                DoCmd.Close acForm, "frmEditQuestions"
                DoCmd.OpenForm "frmMainMenu"
            Else
                MsgBox "You can not save the question before entering a question."
                Exit Sub
            End If
        Else
            MsgBox "Your question must be assigned to a Functional Area before " _
              & "it can be saved"
            Me.FunctionalAreaID.SetFocus
            Exit Sub
        End If
    Else
        DoCmd.Close acForm, "frmEditQuestions"
        DoCmd.OpenForm "frmMainMenu"
    End If

End Sub

What I am trying to do eventually is create a list of departments that the Question has been assigned too.  I will loop through the records found (if any) and put together a list of departments seperated by commas to include in MyTrackChanges.

Thanks!
Lena
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 34

Expert Comment

by:jefftwilley
ID: 18031772
this is a numeric?   [Forms]![frmEditQuestions]![FunctionQuestionRecID]
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 18031773
well looking at the error msg, does the two tables u are using both exist?

tblDepartApplicability
luDepartments

?

dump the sql

debug.print sqlDeptApp

then look in immediate window and try running the sql, it will help u pick up on any errors
0
 
LVL 66

Accepted Solution

by:
Jim Horn earned 1000 total points
ID: 18031778
Dim db as Database
Set db = CurrentDb()

Dim rsApp as DAO.Recordset
Dim strDeptApp as string

strDeptApp = "SELECT da.FunctionQuestionRecID, ld.DepartmentName "
strDeptApp = strDeptApp & "FROM tblDepartApplicability da "
strDeptApp = strDeptApp & "INNER JOIN luDepartments ld ON da.DepartRecID = ld.DepartRecID "
strDeptApp = strDeptApp & "WHERE da.FunctionQuestionRecID = "   & [Forms]![frmEditQuestions]![FunctionQuestionRecID] & " " 
strDeptApp = strDeptApp & "ORDER BY da.FunctionQuestionRecID, ld.DepartmentName;"

Set rsApp = db.OpenRecordset strDeptApp

This assumes that the form you mention is open, and it has a numeric value, and da.FunctionQuestionRecID is numeric
0
 
LVL 34

Assisted Solution

by:jefftwilley
jefftwilley earned 1000 total points
ID: 18031823
since you're on that form...use me.?

strDeptApp = "SELECT tblDepartApplicability.FunctionQuestionRecID," & _
      " luDepartments.DepartmentName FROM tblDepartApplicability INNER JOIN" & _
      " luDepartments ON tblDepartApplicability.DepartRecID =" & _
      " luDepartments.DepartRecID WHERE" & _
      " tblDepartApplicability.FunctionQuestionRecID = " & Me.FunctionQuestionRecID & " ORDER BY" & _
      " tblDepartApplicability.FunctionQuestionRecID, luDepartments.DepartmentName;"
0
 
LVL 10

Author Comment

by:LenaWood
ID: 18031844
Jeff - Yes it is a number.

Rocky - Yes, the tables exist.  Here is what I get when I debug.print the sqlDeptApp:

SELECT tblDepartApplicability.FunctionQuestionRecID, luDepartments.DepartmentName FROM tblDepartApplicability INNER JOIN luDepartments ON tblDepartApplicability.DepartRecID = luDepartments.DepartRecID WHERE tblDepartApplicability.FunctionQuestionRecID = 3251 ORDER BY tblDepartApplicability.FunctionQuestionRecID, luDepartments.DepartmentName

The sql runs fine in a query.

Jim I will give your suggestion a try.

Lena

 
0
 
LVL 34

Expert Comment

by:jefftwilley
ID: 18031864
this might serve if the value is a null?

Dim MyFQID As Long
MyFQID = Nz(Me.functionQuestionRecID.Value, 0)

 strDeptApp = "SELECT tblDepartApplicability.FunctionQuestionRecID," & _
      " luDepartments.DepartmentName FROM tblDepartApplicability INNER JOIN" & _
      " luDepartments ON tblDepartApplicability.DepartRecID =" & _
      " luDepartments.DepartRecID WHERE" & _
      " tblDepartApplicability.FunctionQuestionRecID = " & Me.functionQuestionRecID & " ORDER BY" & _
      " tblDepartApplicability.FunctionQuestionRecID, luDepartments.DepartmentName;"
0
 
LVL 34

Expert Comment

by:jefftwilley
ID: 18031900
Sorry Lena, I keep getting called away...and I think Jim's suggestion already accounts for null but...

Dim MyFQID As Long
MyFQID = Nz(Me.functionQuestionRecID.Value, 0)

 strDeptApp = "SELECT tblDepartApplicability.FunctionQuestionRecID," & _
      " luDepartments.DepartmentName FROM tblDepartApplicability INNER JOIN" & _
      " luDepartments ON tblDepartApplicability.DepartRecID =" & _
      " luDepartments.DepartRecID WHERE" & _
      " tblDepartApplicability.FunctionQuestionRecID = " & MyFQID & " ORDER BY" & _
      " tblDepartApplicability.FunctionQuestionRecID, luDepartments.DepartmentName;"
0
 
LVL 10

Author Comment

by:LenaWood
ID: 18031985
Jim...your solution seems to work although I am not sure what is different other than you gave the tables aliases.  Am I missing something that you changed?  I have been fighting this code for so long my eyes are blurry.

Lena
0
 
LVL 10

Author Comment

by:LenaWood
ID: 18032194
I am wondering if my problem was that I didn't include the ; in my code.  Oh well...it works.  THANK YOU!

Lena
0
 
LVL 66

Expert Comment

by:Jim Horn
ID: 18032232
>Jim...your solution seems to work although I am not sure what is different other than you gave the tables aliases.
Er, actually nothing was different, other than my assumptions, and a possible smart-alec comment on my end like 'readability would help'.  
I was kinda hoping that maybe you mis-spelled something, and that my edit would resolve it.

Thanks for the grade, good luck with your project.  -Jim
0

Featured Post

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question