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) 17 14171
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)
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
"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!)
Its a fair Q. Yes, it has 604 records in it.
I backed it up in the same dbase ==>
tblJobsitesBAKUP.
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)
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.
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.
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
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.
"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
>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.
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
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
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.
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
You were right. Many thanks.
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 This discussion thread is closed Replies have been disabled for this discussion. Similar topics
1 post
views
Thread by Paul |
last post: by
|
reply
views
Thread by Dejan M. |
last post: by
|
2 posts
views
Thread by dskillingstad |
last post: by
|
5 posts
views
Thread by Dave |
last post: by
|
3 posts
views
Thread by Neal |
last post: by
| | | |
2 posts
views
Thread by =?Utf-8?B?c25henp5?= |
last post: by
| | | | | | | | | | |