I have 2 different computers set up the same with Windows XP and Access 2007 and when I use the following code:
DoCmd.OpenReport "Everything2", acViewPreview, , Me.Filter ' Open the file with the filter on
DoCmd.OutputTo acOutputReport, "Everything2", acFormatTXT, ReportFile, False, "", 0
One computer does not write to the report file, it creates the file but doesn't write to it. It's blank.
The other computer works fine and writes the file.
I'm thinking it is a security issue but I am administrator on both computers. Is there something in Access itself that I should look at?
Thanks
Larry
8 3837 - Where is the Declaration for the Output File (ReportFile)"
- Where is ReportFile assigned its Value, and what exactly is it?
It is declared in a module.
The module declaration is this:
Public Const DriveLetter As String = "F:\"
Public Const ReportFile As String = DriveLetter & "ReportFile.txt"
I have also put the file name directly into the statement and still nothing.
It creates the file but does not write to it, so I know it knows where to put it.
I did it that way to make it portable.
Here is one of the sub-routines:
Private Sub cmdViewWeb_Click() 'Purpose: Display filter pictures on webpage
DoCmd.OpenReport "Everything2", acViewPreview, , Me.Filter ' Open the file with the filter on
DoCmd.OutputTo acOutputReport, "Everything2", acFormatTXT, ReportFile, False, "", 0 'Save as text file
Debug.Print ReportFile
Open WebFile For Output As #2 'Open blank file
Open Header For Input As #1 'The file where the header information is
Do Until EOF(1) 'Loop through the data in file #1 until End Of File
Line Input #1, Data 'get the data
Print #2, Data 'append the data into file #2
Loop 'End of loop
Close #1 'Close file #1
Close #2 'Close file #2
Open ReportFile For Input As #2 'The file that contains the data to be copied over
Open WebFile For Append As #1 'The file where the data will be appended
RowNumber = 1 'Initialize RowNumber
PicNum = 1 'Initialize PicNum
Do Until EOF(2) 'Loop until End Of File
Line Input #2, Data 'Get input from file
If Len(Data & "") = 0 Then 'Check for blank lines
'we do nothing
Else
TrimmedData = Right(Data, Len(Data) - InStrRev(Data, "\")) 'trim the file so we can link to actual pictures
'For debugging, remove the leading quote on the next line. Prints to Immediate Window (Ctrl+G).
Debug.Print TrimmedData
' ... and append (write) the data into file number 1 (#1)
PicType = Right(TrimmedData, 3)
Debug.Print PicType
If PicType = "AVI" Or PicType = "avi" Or PicType = "mov" Or PicType = "MOV" Or PicType = "mpg" Or PicType = "MPG" Then
Print #1, " <td><a href=""DB Pics\" & TrimmedData & """ target=""new""><img style="" width: 200; height: 150"" src =""Thumbnail\LogocMovie.jpg ""></td>"
Else
Print #1, " <td><a href=""DB Pics\" & TrimmedData & """ target=""new""><img style="" width: 200; height: 150"" src =""Thumbnail\" & TrimmedData & """></td>"
End If
PicNum = PicNum + 1 'Increment the picture number
RowNumber = RowNumber + 1 'Increment Row Number
End If
If PicNum > 6 Then 'If there are 6 pictures
Print #1, " </tr><tr>" 'Start a new Table row
PicNum = 1 'Reset PicNum for the next row
End If
Loop
Print #1, "</tr></tbody></body></html>" 'Add the end of the html code
' Close the files
Close #2
Close #1
DoCmd.Close acReport, "Everything2", acSaveNo 'Close the report
RowNumber = RowNumber - 1 ' Get the count of pictures right
MessageString = "There are " & RowNumber & " Pictures, Are You Sure? "
Response = MsgBox(MessageString, vbYesNo) ' Give a chance to bail out if there are a lot of pictures
If Response = vbYes Then ' If it is a yes display web page
Call Shell("explorer.exe " & WebFile, vbMaximizedFocus)
Else
' if no Do nothing
End If
End Sub
To see if it is a Security or Network issue, redefine the DriveLetter Constant to point locally, then see if ReportFile is written to: - Public Const DriveLetter As String = "C:\"
-
Public Const ReportFile As String = DriveLetter & "ReportFile.txt"
-
-
DoCmd.OutputTo acOutputReport, "Everything2", acFormatTXT, ReportFile, False, "", 0
-
-
I guess I should have said that the drive it is on is a portable drive so it is actually attached to the computer when it is run.
What should a typical Line of Data look like in ReportFile (obtained via Line Input #2, Data)?
This is a line from the report
\Thumbnail\cRickWed2.jpg
This is a reference to a picture to be displayed on a web page. The output after putting it together would look like this:
<div class="panel"><a href="DB Pics\cArt01.jpg"Target ="new"><img src="Slides\cArt01.jpg"/></a></div>
This particular one is for a slide.
If all else fails, you can manually create the Text File from the Record Souorce for the Everything2 Report.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Victor Kaiser |
last post by:
I am using DoCmd.OutputTo to allow users to save Access reports in
snapshot format or other desired formats. Once the user selects the
desired format and clicks "OK", a dialog box appears that...
|
by: deko |
last post by:
This code is behind a button that exports the contents of a query
("qryXL_Tx") to an Excel spreadsheet. It works fine the first time, but
will not run a second time. When I go to look at my...
|
by: Frank Barnhart |
last post by:
We have an application which runs Access under automation.
With Access 97, the app included this line to send a report to a text
file:
myAccessObject.DoCmd.OutputTo acOutputReport, ,...
|
by: Randy King |
last post by:
Newbie here, so please bear with me.
I have a module that just hangs. I have tracked it down to this line in
the genMappings() module:
DoCmd.OutputTo acQuery, "Mappings", acFormatXLS, _...
|
by: Robert Langen |
last post by:
I'm calling an Access XP application from an Outlook XP appointment form.
Everything works, but the lines
DoCmd.OutputTo acOutputReport, "testreport", acFormatRTF, "c:\test.rtf",
False
Docmd.Quit...
|
by: tmountjr |
last post by:
I've got a user who's trying to export a text file with unicode
formatting. When he exports it as straight ascii, some of the foreign
characters (mostly just accent marks and the like - no...
|
by: Ryan |
last post by:
Hello. I was hoping that someone may be able to assist with an issue
that I am experiencing. I have created an Access DB which imports an
Excel File with a particular layout and field naming. ...
|
by: Simon |
last post by:
Dear reader,
With the DoCmd.OutputTo ...... you have the possibility to write a
report to an external location.
In case the external location is an existing file the DoCmd is not...
|
by: jmartmem |
last post by:
Greetings,
I have several Access 2007 reports that I regularly export to individual PDF flat files on a web server. I've successfuly created a module sub to export the reports using the...
|
by: g diddy |
last post by:
Hi, I have used the Docmd.outputto function in various places in my code but for some reason all code that comes afterwards, even msgbox doesn't show. I was just wondering if there is anything that...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
| |