0

I have a macro that runs a series of steps and outputs a report in MS Acces.s I want this report to be named using a variable from my form and stored in a particular file.

I have written VB code to do the same.

It runs perfectly well when i run the code, but from the macro it doesn't work!

Private Sub FileLocator()
If [Forms]![Date Form].[Frame37] = 1 Then
MsgBox ("Working")
x = [Forms]![Date Form].List29
Else
x = [Forms]![Date Form].List25
End If

DoCmd.OutputTo acOutputReport, "41_Webtime less than 40 hours chart", "PDFFormat(*.pdf)", "C:\" & x & "\" & x & ".pdf", True, "", , acExportQualityPrint

End Sub

From my macro i call Forms![Date Form]!FileLocator in RunCode

4
  • possible duplicate of MS Access RunCode Macro cannot find my procedure Commented Mar 2, 2014 at 15:08
  • Nope! Changing it to function didn't work either. Doesn't show any error. But just doesnt run the function or sub Commented Mar 2, 2014 at 15:23
  • 1
    The function needs to be in a "regular" VBA Module, not in the Class Module for a specific form. In Access do Create > Module and then move the function into there as a Public Function. Commented Mar 2, 2014 at 15:27
  • Tried it doesn't work :( no error again. Just refuses to pick the function. It is in a separate module as well as under my form class object. How do i call the module function? I'm currently using Forms![Date Form]!FileLocator in RunCode Commented Mar 3, 2014 at 17:21

1 Answer 1

1

Just had this issue myself, turns out you cannot have the module name the same as the function name.

Hope that is your issue as well.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.