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

Can't see or connect to Module

Status
Not open for further replies.

lewis33

Technical User
May 21, 2001
64
US
Hi, I created a module from a macro in Access 97 and it gave it a name like 'PDI Search Macro' and it looks like:

Function PDI_SEARCH_MACRO()
On Error GoTo PDI_SEARCH_MACRO_Err

DoCmd.OpenForm "Prompt Idea", acNormal, "", "", , acNormal
DoCmd.OpenQuery "PDI SEARCH QUERY MAIN", acNormal, acEdit
DoCmd.OpenQuery "PDI SEARCH QUERY PCP", acNormal, acEdit
DoCmd.OpenQuery "PDI SEARCH QUERY SPC", acNormal, acEdit
DoCmd.OpenQuery "PDI SEARCH QUERY ANC", acNormal, acEdit
DoCmd.OpenQuery "PDI SEARCH QUERY INS", acNormal, acEdit
DoCmd.OpenQuery "TOTAL PDI SEARCH QUERIES", acNormal, acEdit
DoCmd.Close acForm, "Prompt Idea"
DoCmd.OpenReport "rpt_PPD sample columns", acPreview, "", ""
DoCmd.Close acQuery, "PDI SEARCH QUERY ANC"
DoCmd.Close acQuery, "PDI SEARCH QUERY INS"
DoCmd.Close acQuery, "PDI SEARCH QUERY MAIN"
DoCmd.Close acQuery, "PDI SEARCH QUERY PCP"
DoCmd.Close acQuery, "PDI SEARCH QUERY SPC"
DoCmd.Close acQuery, "TOTAL PDI SEARCH QUERIES"
PDI_SEARCH_MACRO_Exit:
Exit Function
PDI_SEARCH_MACRO_Err:
MsgBox Error$
Resume PDI_SEARCH_MACRO_Exit
End Function

However, when I got back to my form and go to the command button's On Click property and [event procedure] -it doesn't show me this function. I look under General and only find something like
Private Sub PDI_SEARCH_MACRO1()
End Sub

Which is the wrong name- Not sure how to connect the code from the converted macro. Thanks.
 
I'm not sure I understand you'r question completely, but...

Are you trying to "see" the function the same way as in Excel or Word or as the macros in Access? If so, Access VBA doesn't work that way.

To "connect" to it, you need to call it, but first:

It seems you're not returning any value from the function, so I'd say, make it a sub (simply replace the word "Function" with "Sub" and "End Function" with "End Sub"

To call the sub:
In your buttons on click event (you click the button with 3 dots), you'l get a form sub called. Within the sub name and end sub you call the sub:

sub your_button_name_Click()
call PDI_SEARCH_MACRO
end sub

HTH Roy-Vidar
 
Thanks Roy- I'll go ahead and give it a try.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top