For the programmers

Daxton A.

Registered User.
Local time
Today, 22:58
Joined
Dec 30, 2002
Messages
65
I am using the OutputTo Statement.
When i leave the filename to Output to....blank, access prompts me for the file, this is good, that's what i want it to do. But lets say i want to then take and open the file in excel. How would i code that?

I know that i somehow have to set an object variable = to the textbox on the popup where the name of the file is typed. But i dont know how to do that with a default dialog box. I also dont know what code to use to open Excel or the file in excel. Do you have an idea on how to accomplish this task?

Thanxamillion,
Daxton
 
Here are some ideas.

A: Capturing the filename. Let's start with your idea of using a variable. Instead of using the default dialog box, define a variable and fill it by means of a dialog box. You can make it look and act just like the default if you choose. Now simply insert the variable in your OutputTo statement instead of leaving it blank.

B. Starting the Excel file. Try this under a button (change the path to reflect your own setup):

Private Sub RunExcel_Click()
On Error GoTo Err_RunExcel_Click

Dim stAppName As String

stAppName = "C:\Program Files\Microsoft Office\Office10\EXCEL.EXE " & strVariable & """
Call Shell(stAppName, 1)

Exit_RunExcel_Click:
Exit Sub

Err_RunExcel_Click:
MsgBox Err.Description
Resume Exit_Command31_Click

End Sub
 
What about this then:

Code:
Public Function Confirm(StrMessage As String) As Boolean
'this function asks a question of the user and returns tru if user choose yes

Dim BytChoice As Byte
BytChoice = MsgBox(StrMessage, vbQuestion + vbYesNo + vbDefaultButton2, conAppName)
If BytChoice = vbYes Then
Confirm = True
Else
Confirm = False
End If
End Function

the above returns a true or false value based on the users response to a question posed.

copy this function into a public module then use the confirm function to return true or false to th AutoStart argument of the OutPutTo method as follows...

Code:
DoCmd.OutputTo acOutputQuery, "ObjectName", acFormatXLS, , Confirm("Open the file?")
 

Users who are viewing this thread

Back
Top Bottom