Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Saving a form as a Data Access Page 3

Status
Not open for further replies.

PortyAL

Technical User
May 13, 2005
126
GB
Hi

I have a open form which I want to save as a data access page. I appreciate I can use "File" "Save as" , choose "Data Access Page" etc, but I wanting to automate the proces and go directly to the file location dialog if possible.

I found the following code:

Code:
DoCmd.RunCommand acCmdSaveAsDataAccessPage

but if I try running this it gives the following error

The command or action " isn't available now.

Any advice would be appreciated.

Thanks

AL
 
Al, try this:

Code:
    Dim MyPageName As String
    Dim dapNewPage As DataAccessPage
    
    MyPageName = "newPage.htm"
    
    Set dapNewPage = Application.CreateDataAccessPage(MyPageName, True)
    DoCmd.Close acDataAccessPage, dapNewPage.Name, acSaveYes

Nick
 
Thanks for that Nick.

One problem - your code does create a data access page but the page is blank.

The form I'm trying to create the page from is called "layout". Does this need to be built into the code in some way?

Thanks again for your help.

AL
 
Really sorry mate I'm stumpted with this one! Been trying different variations of Saves/Save As commands all day and can't get anything to work. acCmdSaveAsDataAccessPage is not really well document anywhere, which I imagine you found out!!

Hopefully someone else will pick this up and enlighten us both!

Nick
 
Thanks anyway

I've been trying various things myself. Do you have any idea how to use the "Do.Cmd OutputTo acOutputDataAccessPage" command?

This gets me as far as the file name and location dialog, but when I put in a file name, an error shows saying Access can't find the file name. I tried running your code first to create a blank DAP then used the above command but the same error still showed.

AL
 
Al, I tried this earlier also but didn't get anywhere, infact I didn't even get as far as you described.

Code:
DoCmd.OutputTo acOutputDataAccessPage, , acFormatHTML, "C:\Documents and Settings\344033\Desktop\"
 
And what about this ?
DoCmd.OutputTo acOutputForm, "layout", acFormatDAP, "\path\to\file.htm"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Or this for a static DAP:
Private Sub Command12_Click()
DoCmd.OutputTo acOutputForm, "Employee_form_to_dap", acFormatHTML, "DapTest7.htm"
End Sub
 
Thanks PHV / fneily.

This code does exactly what I want!

Cheers

AL
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top