472,364 Members | 2,087 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,364 software developers and data experts.

Database engine cannot find table. Why not?

MLH
The Microsoft Jt database engine can not find
tblJobSites, error #3078. That's what I get when
executing this code...

Private Sub Command1_Click()
Dim MyWorkspace As Workspace
Set MyWorkspace = DBEngine.Workspaces(0)
Dim MyDB As Database
Dim MyQueryDef As QueryDef, MyRecSet As Recordset
Dim MyPeriod As String, MyRand As Double
Set MyDB = MyWorkspace.Databases(0)
Set MyQueryDef = MyDB.CreateQueryDef("")

With MyQueryDef
' Create temporary QueryDef.
.SQL = "SELECT [Period] FROM tblJobsites WHERE [Period]='M'"
Set MyRecSet = .OpenRecordset()
MyRecSet.MoveFirst
End With

Debug reports the problematic line ...
Set MyRecSet = .OpenRecordset()

What have I done wrong here?

(frmProgrammerOnly, Command1 button click, deadpest.mdb)

Nov 13 '05 #1
17 14367
I hate to ask the obvious, but do you have a table named tblJobsites? Might
it actually be tblJobsite or some other variation?

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"MLH" <CR**@NorthState.net> wrote in message
news:o7********************************@4ax.com...
The Microsoft Jt database engine can not find
tblJobSites, error #3078. That's what I get when
executing this code...

Private Sub Command1_Click()
Dim MyWorkspace As Workspace
Set MyWorkspace = DBEngine.Workspaces(0)
Dim MyDB As Database
Dim MyQueryDef As QueryDef, MyRecSet As Recordset
Dim MyPeriod As String, MyRand As Double
Set MyDB = MyWorkspace.Databases(0)
Set MyQueryDef = MyDB.CreateQueryDef("")

With MyQueryDef
' Create temporary QueryDef.
.SQL = "SELECT [Period] FROM tblJobsites WHERE [Period]='M'"
Set MyRecSet = .OpenRecordset()
MyRecSet.MoveFirst
End With

Debug reports the problematic line ...
Set MyRecSet = .OpenRecordset()

What have I done wrong here?

(frmProgrammerOnly, Command1 button click, deadpest.mdb)

Nov 13 '05 #2
Br
MLH <CR**@NorthState.net> wrote:
The Microsoft Jt database engine can not find
tblJobSites, error #3078. That's what I get when
executing this code...

Private Sub Command1_Click()
Dim MyWorkspace As Workspace
Set MyWorkspace = DBEngine.Workspaces(0)
Dim MyDB As Database
Dim MyQueryDef As QueryDef, MyRecSet As Recordset
Dim MyPeriod As String, MyRand As Double
Set MyDB = MyWorkspace.Databases(0)
Set MyQueryDef = MyDB.CreateQueryDef("")

With MyQueryDef
' Create temporary QueryDef.
.SQL = "SELECT [Period] FROM tblJobsites WHERE [Period]='M'"
^^^

Have you forgotten the ; character at the end of your SQL statement???

Set MyRecSet = .OpenRecordset()
MyRecSet.MoveFirst
End With

Debug reports the problematic line ...
Set MyRecSet = .OpenRecordset()

What have I done wrong here?

(frmProgrammerOnly, Command1 button click, deadpest.mdb)


--
regards,

Bradley

A Christian Response
http://www.pastornet.net.au/response
Nov 13 '05 #3

"Br@dley" <n0****@4u.com> wrote in message
news:OV************@news-server.bigpond.net.au...
MLH <CR**@NorthState.net> wrote:
Have you forgotten the ; character at the end of your SQL statement???


The semicolon isn't required.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


Nov 13 '05 #4
MLH
Its a fair Q. Yes, it has 604 records in it.
I backed it up in the same dbase ==>
tblJobsitesBAKUP.
Nov 13 '05 #5
MLH
Have tried both with and without the semicolon.
Same err rtnd either way.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Have you forgotten the ; character at the end of your SQL statement???

Set MyRecSet = .OpenRecordset()
MyRecSet.MoveFirst
End With

Debug reports the problematic line ...
Set MyRecSet = .OpenRecordset()

What have I done wrong here?

(frmProgrammerOnly, Command1 button click, deadpest.mdb)


Nov 13 '05 #6
MLH
The precise error message...

Run-time error '3078':
The Microsoft Jet database engine cannot find the input table or query
'tblJobsites'. Make sure it exists and that its name is spelled
correctly.

I have copied the table to another table named 'a' and tried the same
code again. It reports not being able to find 'a' as well. I have
closed and reopened the database. Perhaps there's something
wrong with my code syntax. I would appreciate you checking.
Nov 13 '05 #7
MLH
Notice if I slightly change the SQL assignment to this...
Private Sub Command1_Click()
Dim MyWS As Workspace
Set MyWS = DBEngine.Workspaces(0)
Dim MyDB As Database
Dim MyQD As QueryDef, MyRecSet As Recordset
Dim MyPeriod As String, MyRand As Double
Set MyDB = MyWS.Databases(0)
Set MyQD = MyDB.CreateQueryDef("SELECT [Period] FROM tblJobsites
WHERE [Period]='M';")

With MyQD
' Create temporary QueryDef.
' .SQL = "SELECT [Period] FROM tblJobsites WHERE [Period]='M';"
Set MyRecSet = .OpenRecordset 'This line gave me prob -
Access said it couldn't find tblJobsites. Why?
MyRecSet.MoveFirst
End With

You see where I rem'd out the .SQL assignment in the With clause?
I put it in a few lines up - just before the With statement. Debog
reports the exact same error, citing that line as the problematic
line. How can the Set MyQD line fail??? I just don't understand.
Nov 13 '05 #8
MLH
Also, if I remove the square brackets from the Period fieldname in the
SQL statement, the error is different and occurs on a different
line...

Private Sub Command1_Click()
Dim MyWS As Workspace
Set MyWS = DBEngine.Workspaces(0)
Dim MyDB As Database
Dim MyQD As QueryDef, MyRecSet As Recordset
Dim MyPeriod As String, MyRand As Double
Set MyDB = MyWS.Databases(0)
' Set MyQD = MyDB.CreateQueryDef("SELECT [Period] FROM tblJobsites
WHERE [Period]='M';")
Set MyQD = MyDB.CreateQueryDef("SELECT Period FROM tblJobsites
WHERE Period='M';")

With MyQD
' Create temporary QueryDef.
' .SQL = "SELECT [Period] FROM tblJobsites WHERE [Period]='M';"
Set MyRecSet = .OpenRecordset 'This line gave me prob -
Access said it couldn't find tblJobsites. Why?
MyRecSet.MoveFirst
End With
Runtime error 3067...
Query input must contain at least one table or query.

Debug reports this as the problematic line...
Set MyRecSet = .OpenRecordset
Nov 13 '05 #9
MLH
I compacted the database to db1.mdb and repaired it
successfully. Then I opened db1 and ran this code again...

Private Sub Command1_Click()
Dim MyWS As Workspace
Set MyWS = DBEngine.Workspaces(0)
Dim MyDB As Database
Dim MyQD As QueryDef, MyRecSet As Recordset
Dim MyPeriod As String, MyRand As Double
Set MyDB = MyWS.Databases(0)
' Set MyQD = MyDB.CreateQueryDef("SELECT [Period] FROM tblJobsites
WHERE [Period]='M';")
Set MyQD = MyDB.CreateQueryDef("SELECT Period FROM tblJobsites
WHERE Period='M';")

With MyQD
' Create temporary QueryDef.
' .SQL = "SELECT [Period] FROM tblJobsites WHERE [Period]='M';"
Set MyRecSet = .OpenRecordset 'This line gave me prob -
Access said it couldn't find tblJobsites. Why?
MyRecSet.MoveFirst
End With
This time the error returned was different...
Run-time error 3012...
Object "SELECT Period FROM tblJobsites WHERE Period="M';" already
exists.

Am I not exiting the Workspace? What's going on. If I stop & restart
Access, this error is not the first, but you can bet it'll be the
second if I run the code again in the same instance of Access.
Nov 13 '05 #10

"MLH" <CR**@NorthState.net> wrote in message
news:nh********************************@4ax.com...
Notice if I slightly change the SQL assignment to this...
Private Sub Command1_Click()
Dim MyWS As Workspace
Set MyWS = DBEngine.Workspaces(0)
Dim MyDB As Database
Dim MyQD As QueryDef, MyRecSet As Recordset
Dim MyPeriod As String, MyRand As Double
Set MyDB = MyWS.Databases(0)
Set MyQD = MyDB.CreateQueryDef("SELECT [Period] FROM tblJobsites
WHERE [Period]='M';")

With MyQD
' Create temporary QueryDef.
' .SQL = "SELECT [Period] FROM tblJobsites WHERE [Period]='M';"
Set MyRecSet = .OpenRecordset 'This line gave me prob -
Access said it couldn't find tblJobsites. Why?
MyRecSet.MoveFirst
End With

You see where I rem'd out the .SQL assignment in the With clause?
I put it in a few lines up - just before the With statement. Debog
reports the exact same error, citing that line as the problematic
line. How can the Set MyQD line fail??? I just don't understand.


The first part of the CreateQueryDef method is the name of the query being
created. Try
Set MyQD = MyDB.CreateQueryDef("", "SELECT [Period] FROM tblJobsites WHERE
[Period]='M';") or

Set MyQD = MyDB.CreateQueryDef("TempQuery1", "SELECT [Period] FROM
tblJobsites WHERE [Period]='M';")
Remember this will add a new query under the queries collection in the
database window.

Also what are you trying to do with the newly created query? If you're just
going to loop through the records, try using a recordset instead.

Jeff

Nov 13 '05 #11
MLH
>Run-time error 3012...
Object "SELECT Period FROM tblJobsites WHERE Period="M';" already
exists.


I am getting this error everytime I runt the code now. Even when
I reboot the PC, launch Access 97, open the database and run
the code for the first time in the new instance of Access.
Nov 13 '05 #12
Br
MLH <CR**@NorthState.net> wrote:
Also, if I remove the square brackets from the Period fieldname in the
SQL statement, the error is different and occurs on a different
line...

Private Sub Command1_Click()
Dim MyWS As Workspace
Set MyWS = DBEngine.Workspaces(0)
Dim MyDB As Database
Dim MyQD As QueryDef, MyRecSet As Recordset
Dim MyPeriod As String, MyRand As Double
Set MyDB = MyWS.Databases(0)
' Set MyQD = MyDB.CreateQueryDef("SELECT [Period] FROM tblJobsites
WHERE [Period]='M';")
Set MyQD = MyDB.CreateQueryDef("SELECT Period FROM tblJobsites
WHERE Period='M';")

With MyQD
' Create temporary QueryDef.
' .SQL = "SELECT [Period] FROM tblJobsites WHERE [Period]='M';"
Set MyRecSet = .OpenRecordset 'This line gave me prob -
Access said it couldn't find tblJobsites. Why?
MyRecSet.MoveFirst
End With
Runtime error 3067...
Query input must contain at least one table or query.

Debug reports this as the problematic line...
Set MyRecSet = .OpenRecordset


Did you bother to check the Access help? A quick look showed your syntax
problem.. you need to specifiy an empty string as the QueryDef name.

This should work...

Dim MyWS As Workspace
Set MyWS = DBEngine.Workspaces(0)
Dim MyDB As Database
Dim MyQD As QueryDef, MyRecSet As Recordset
Dim MyPeriod As String, MyRand As Double
Set MyDB = MyWS.Databases(0)
Set MyQD = MyDB .CreateQueryDef("")
With MyQD
.SQL = "SELECT [Period] FROM tblJobsites WHERE [Period]='M'"
Set MyRecSet = .OpenRecordset()
MyRecSet.MoveFirst
End With

OR

Dim MyWS As Workspace
Set MyWS = DBEngine.Workspaces(0)
Dim MyDB As Database
Dim MyQD As QueryDef, MyRecSet As Recordset
Dim MyPeriod As String, MyRand As Double
Set MyDB = MyWS.Databases(0)
Set MyQD = MyDB .CreateQueryDef("", SELECT [Period] FROM tblJobsites
WHERE [Period]='M')
With MyQD
Set MyRecSet = .OpenRecordset()
MyRecSet.MoveFirst
End With

--
regards,

Bradley

A Christian Response
http://www.pastornet.net.au/response
Nov 13 '05 #13
Br
MLH <CR**@NorthState.net> wrote:
I compacted the database to db1.mdb and repaired it
successfully. Then I opened db1 and ran this code again...

Private Sub Command1_Click()
Dim MyWS As Workspace
Set MyWS = DBEngine.Workspaces(0)
Dim MyDB As Database
Dim MyQD As QueryDef, MyRecSet As Recordset
Dim MyPeriod As String, MyRand As Double
Set MyDB = MyWS.Databases(0)
' Set MyQD = MyDB.CreateQueryDef("SELECT [Period] FROM tblJobsites
WHERE [Period]='M';")
Set MyQD = MyDB.CreateQueryDef("SELECT Period FROM tblJobsites
WHERE Period='M';")

With MyQD
' Create temporary QueryDef.
' .SQL = "SELECT [Period] FROM tblJobsites WHERE [Period]='M';"
Set MyRecSet = .OpenRecordset 'This line gave me prob -
Access said it couldn't find tblJobsites. Why?
MyRecSet.MoveFirst
End With
This time the error returned was different...
Run-time error 3012...
Object "SELECT Period FROM tblJobsites WHERE Period="M';" already
exists.

Am I not exiting the Workspace? What's going on. If I stop & restart
Access, this error is not the first, but you can bet it'll be the
second if I run the code again in the same instance of Access.


Look under your Queries list... I suspect you've created a query named
"SELECT Period FROM tblJobsites WHERE Period="M';" !!!???

See my previous post.
--
regards,

Bradley

A Christian Response
http://www.pastornet.net.au/response
Nov 13 '05 #14
MLH
Thanks Jeff. I have a hunch this'll work. BTW, all I'm gonna do is
loop through the records. I thought I needed to have a querydef
for that in DAO.

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

On Wed, 25 May 2005 12:23:54 +1200, "Jeff Smith"
<No****@Not.This.Address> wrote:
Try
Set MyQD = MyDB.CreateQueryDef("", "SELECT [Period] FROM tblJobsites WHERE
[Period]='M';") or

Set MyQD = MyDB.CreateQueryDef("TempQuery1", "SELECT [Period] FROM
tblJobsites WHERE [Period]='M';")
Remember this will add a new query under the queries collection in the
database window.

Also what are you trying to do with the newly created query? If you're just
going to loop through the records, try using a recordset instead.


Nov 13 '05 #15
Br
MLH <CR**@NorthState.net> wrote:
Thanks Jeff. I have a hunch this'll work. BTW, all I'm gonna do is
loop through the records. I thought I needed to have a querydef
for that in DAO.
Nope..

Just do something like....

mySQL = "SELECT [Period] FROM tblJobsitesWHERE [Period]='M';"
Set myRS = CurrentDB.OpenRecordset(mySQL, dbOpenDynaset)
myRS.MoveFirst
Do Until myRS.EOF
'code
myRS.MoveNext
Loop

On Wed, 25 May 2005 12:23:54 +1200, "Jeff Smith"
<No****@Not.This.Address> wrote:
Try
Set MyQD = MyDB.CreateQueryDef("", "SELECT [Period] FROM tblJobsites
WHERE [Period]='M';") or

Set MyQD = MyDB.CreateQueryDef("TempQuery1", "SELECT [Period] FROM
tblJobsites WHERE [Period]='M';")
Remember this will add a new query under the queries collection in
the database window.

Also what are you trying to do with the newly created query? If
you're just going to loop through the records, try using a recordset
instead.


--
regards,

Bradley

A Christian Response
http://www.pastornet.net.au/response
Nov 13 '05 #16
MLH
You were right. Many thanks.
Nov 13 '05 #17
MLH <CR**@NorthState.net> wrote in
news:o7********************************@4ax.com:
The Microsoft Jt database engine can not find
tblJobSites, error #3078. That's what I get when
executing this code...

Private Sub Command1_Click()
Dim MyWorkspace As Workspace
Set MyWorkspace = DBEngine.Workspaces(0)
Dim MyDB As Database
Dim MyQueryDef As QueryDef, MyRecSet As Recordset
Dim MyPeriod As String, MyRand As Double
Set MyDB = MyWorkspace.Databases(0)
Set MyQueryDef = MyDB.CreateQueryDef("")

With MyQueryDef
' Create temporary QueryDef.
.SQL = "SELECT [Period] FROM tblJobsites WHERE
[Period]='M'" Set MyRecSet = .OpenRecordset()
MyRecSet.MoveFirst
End With

Debug reports the problematic line ...
Set MyRecSet = .OpenRecordset()

What have I done wrong here?

(frmProgrammerOnly, Command1 button click, deadpest.mdb)


If you paste the SQL into the query designer's SQL view, does it
give you the same error?

I don't quite understand why you're using a querydef. Why not just
open a recordset with the SQL?

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #18

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Paul | last post by:
Hello, I know there are other messages concerning this error message, but they all look so confusing to me. I have an application that uses an Access database. No problems with permissions....
0
by: Dejan M. | last post by:
Please can you help me with this problem: In the next form, when I Add new person who is not registered in the base I had the massage: The Microsoft Jet database engine cannot find a record in...
2
by: dskillingstad | last post by:
I'm building a tracking system and I'm having some problems. I thought this was relatively easy, but.... I have the following tables and fields (abbreviated): tblPermitMain PermitID - pk...
5
by: Dave | last post by:
This is my first .NET project (although I am experienced with VS6 and InterDev). I am simply trying to set up a basic ASPX project and connect to an Access database (following the instructions in...
3
by: Neal | last post by:
Hi All I am trying to connect from ASP.Net app to an Access Db. If i don't specify a userid an pwd.. I get this error The Microsoft Jet database engine cannot open the file 'C:\Documents and...
1
by: babyjek | last post by:
SELECT ProjectID, ProjectName, ProjectDescription, SequenceNumber, LastUpdateDate FROM Project WHERE ProjectID = @ProjectID; (The Microsoft Jet database engine cannot find the input table or...
3
gcoaster
by: gcoaster | last post by:
Hello! I am having problem with DLookup Function DLookup looks on form, and finds the combobox = cboFullName and then compares it to the column clientID in tblCLIENTS table. if they match,...
6
by: warpcon | last post by:
Im trying to build a database starting with one of the templates that come with access. I took out the employee part in all the tables and forms. Now when I pull up a workorder and then try to view...
2
by: =?Utf-8?B?c25henp5?= | last post by:
I have created an web application using Visual Studio 2008. The application works OK in Debug. However it does not work after publish. The following message appers "The Microsoft Jet database...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.