You are correct. If the file does not exist, it will create it. If the
file already exists, it will over-write it.
However, this confusing error can occur because of a variety of problems.
First thing to check is to run the query you're trying to export. If there
is a run-time error in the query, it can sometimes report this error
message.
--
--Roger Carlson
MS Access MVP
Access Database Samples:
www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
Hi again Roger, Yes, it's a table. I'm not getting the same error so
I'm
pretty sure it works. But now I'm getting an error on the export.
I have written this at the bottom of my VB (see my previous SQL text):
DoCmd.TransferText acExportDelim, "RevisedCensus1ExportSpec",
"qExportRevisedCensus1", "S:\RPS\PTS\CensusConversion\ToRelius\" &
[Forms]![fCensus1Conversion]![RunThisOne] & ".csv", False
MsgBox "Data has been exported to the S:\RPS\PTS\CensusConversion\ToRelius
folder and named " & Me.RunThisOne & ".csv."
For some reason, it thinks the new file should already exist. I get the
error: Microsoft Visual Basic Run-time error '3011': The Microsoft Jet
database engine could not find the object 'GP0013.csv'. Make sure the
object
exists and that you spell its name and the path name correctly.
I know the file must exist to IMPORT but it shouldn't have to exist to
EXPORT. Can you see what I've done wrong?
You have been an absolute God-send on this project for me. Thank you SO
much for keeping the thread open. Thanks in advance for any additional
help.
--
Bonnie
:
Oh, I see. The context I was referring to (and what I could not
understand)
is that GP0013Revised is a table. Correct? This code inserts different
tables within the query dynamcially. What you *want* to see in the SQL
is:
format(GP0013Revised![Status Date], "mm/dd/yyyy")
which will format the date as you want it. So in your code to create
the
SQL, it should look something like this:
strSQL = strSQL & "Format(" & [Forms]![fCensus1Conversion]![RunThisOne]
&
"Revised.[Status Date], ""mm/dd/yyyy"") "
--
--Roger Carlson
MS Access MVP
Access Database Samples:
www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
Morning Roger! Sorry for not understanding the context inquiry.
Probably
why I'm still getting an error. I think it has to do with the extra
quotes
needed for text fields.
My form shows a contract record and the text field [RunThisOne] is the
contract number (letters 'GP' and 4 digits, for example GP0013).
I'm getting this Microsoft Visual Basic error: Run-time error '3075':
Syntax error (missing operator) in query expression 'GP0013
Format(Revised.[Status Date], "mm/dd/yyyy")'.
I am SOOOO close! I'm sure it's those quotes that are holding it up.
Can
you help? I just hope I've explained it well enough. Thanks again
for
your
help.
--
Bonnie
:
Showing the SQL is good. However, what I meant by context is what
[Forms]![fCensus1Conversion]![RunThisOne] is and what it shows on
the
screen
which would be interjected into your SQL statement.
You are absolutely right about the paren. It should be:
strSQL = strSQL & [Forms]![fCensus1Conversion]![RunThisOne] &
" Format(Revised.[Status Date], ""mm/dd/yyyy"") "
Again, this is just a guess.
--
--Roger Carlson
MS Access MVP
Access Database Samples:
www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
Hi Roger,
Thanks for the reply. I'm getting an error. I am using this to
alter
an
existing query so it will find the 2 tables that are named with
the
value
in
[RunThisOne]. It exports a comma delimited file. My 3 date
fields
are
exporting time zeros after the date rather than just the date.
Wasn't sure what you meant by context below but here's my code:
Private Sub ExpRelius_Click()
Dim strSQL As String
Dim dbsCurrent As Database
Dim qryTest As QueryDef
Set dbsCurrent = CurrentDb
strSQL = "SELECT "
strSQL = strSQL & "IIf((" &
[Forms]![fCensus1Conversion]![RunThisOne]
&
"Revised![SSN])= '000000000', "
strSQL = strSQL & [Forms]![fCensus1Conversion]![RunThisOne] &
"Copy![SSN],
"
strSQL = strSQL & [Forms]![fCensus1Conversion]![RunThisOne] &
"Revised![SSN]) AS Social, "
strSQL = strSQL & [Forms]![fCensus1Conversion]![RunThisOne] &
"Revised.[First Name], "
strSQL = strSQL & [Forms]![fCensus1Conversion]![RunThisOne] &
"Revised.[Last
Name], "
strSQL = strSQL & [Forms]![fCensus1Conversion]![RunThisOne] &
"Revised.Gender, "
strSQL = strSQL & [Forms]![fCensus1Conversion]![RunThisOne] &
"Revised.[Date
of Birth], "
strSQL = strSQL & [Forms]![fCensus1Conversion]![RunThisOne] &
"Revised.[Date
of Hire], "
strSQL = strSQL & [Forms]![fCensus1Conversion]![RunThisOne] &
"Revised.Hours, "
strSQL = strSQL & [Forms]![fCensus1Conversion]![RunThisOne] &
"Revised.Compensation, "
strSQL = strSQL & [Forms]![fCensus1Conversion]![RunThisOne] &
"Revised.[Deferral Amount], "
strSQL = strSQL & [Forms]![fCensus1Conversion]![RunThisOne] &
"Revised.[Excludable Compensation], "
strSQL = strSQL & [Forms]![fCensus1Conversion]![RunThisOne] &
"Revised.[Section 125], "
strSQL = strSQL & [Forms]![fCensus1Conversion]![RunThisOne] &
"Revised.[Status Code], "
strSQL = strSQL & [Forms]![fCensus1Conversion]![RunThisOne] &
"Revised.[Status Date] "
strSQL = strSQL & " FROM "
strSQL = strSQL & [Forms]![fCensus1Conversion]![RunThisOne] &
"Copy
RIGHT
Join "
strSQL = strSQL & [Forms]![fCensus1Conversion]![RunThisOne] &
"Revised
ON
"
strSQL = strSQL & [Forms]![fCensus1Conversion]![RunThisOne] &
"Copy.ID
= "
strSQL = strSQL & [Forms]![fCensus1Conversion]![RunThisOne] &
"Revised.ID
"
strSQL = strSQL & "WITH OWNERACCESS OPTION;"
'MsgBox strSQL
'change "YourQuery" to the name of your query
Set qryTest = dbsCurrent.QueryDefs("qExportRevisedCensus1")
qryTest.SQL = strSQL
'other code
Set dbsCurrent = Nothing
Set qryTest = Nothing
'--------------------------------
'Uncomment the MsgBox line or add a Debug.Pring strSQL line.
'It should give you the correct SQL for the value selected in the
'"RunThisOne" combo box.
DoCmd.TransferText acExportDelim, "RevisedCensus1ExportSpec",
"qExportRevisedCensus1", "S:\RPS\PTS\CensusConversion\ToRelius\" &
[Forms]![fCensus1Conversion]![RunThisOne] & ".csv", False
MsgBox "Data has been exported to the
S:\RPS\PTS\CensusConversion\ToRelius
folder and named " & Me.RunThisOne & ".csv."
End Sub
I messed up the quotes or something. Isnt' there a parenthesis
missing?
Getting the missing operator run-time error 3075.
Thanks again for your help!
--
Bonnie
: