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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I run a macro in excel from data exported from an Access Form

Status
Not open for further replies.

applejackson

Programmer
Jun 11, 2002
4
US
I am looking for some help with formatting an excel workbook (upon activation) that has been exported from an Access 2000 form with VB on the back end.

I had originally thought that I needed to do this through a module and procedure, but I have not written many so I am not sure. I also tried to do this by loading a custom button with a macro to the workbook when it loads.

This form exports Audio CDR files from a query based on the bridge and date select by the user on the form.

Here is the code for the export

Private Sub Command6_Click()
If Me.Combo2 = "Aries" Then
DoCmd.OutputTo acOutputQuery, "A_CDR_out", acFormatXLS, "Aries.xls", True
DoCmd.Close acForm, "CDRs", acSaveNo
DoCmd.OpenForm "CDR Navigator", acNormal, , , acFormPropertySettings, acWindowNormal

ElseIf Me.Combo2 = "Gemini" Then
DoCmd.OutputTo acOutputQuery, "g_CDR_out", acFormatXLS, "Gemini.xls", True
DoCmd.Close acForm, "CDRs", acSaveNo
DoCmd.OpenForm "CDR Navigator", acNormal, , , acFormPropertySettings, acWindowNormal

ElseIf Me.Combo2 = "Orion" Then
DoCmd.OutputTo acOutputQuery, "g_CDR_out", acFormatXLS, "Orion.xls", True
DoCmd.Close acForm, "CDRs", acSaveNo
DoCmd.OpenForm "CDR Navigator", acNormal, , , acFormPropertySettings, acWindowNormal

ElseIf Me.Combo2 = "Zeus" Then
DoCmd.OutputTo acOutputQuery, "g_CDR_out", acFormatXLS, "Zeus.xls", True
DoCmd.Close acForm, "CDRs", acSaveNo
DoCmd.OpenForm "CDR Navigator", acNormal, , , acFormPropertySettings, acWindowNormal

Else

End If

End Sub

The code for the module or macro looks something like:

Sub Output()

Columns("B:C").Select
Selection.NumberFormat = "h:mm:ss AM/PM"
Columns("F:F").EntireColumn.AutoFit
Columns("F:F").Select
Selection.NumberFormat = "0"
Columns("G:G").EntireColumn.AutoFit

End Sub

Any help would be great :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top