DoCmd.OpenModule question

  • Thread starter Thread starter Ryis
  • Start date Start date
R

Ryis

Hello,

I have a button which opens a module to a specific function as the following

DoCmd.OpenModule "ReportFunctions", Me!MODULE

Me!MODULE= a column in a table example "opencpar"

The module opens but in VB to the specific point, I want the module to run
the code..here is the code:

Private Sub opencpar()
On Error GoTo Err_opencpar

Dim stDocName As String
Dim stLinkLocation As String


stDocName = Forms![MAIN MENU]![TYPE OF REPORT]
stLinkLocation = "[LOCATION]=" & "'" & Forms![MAIN MENU]![REPORT
LOCATION] & "'"


If Forms![MAIN MENU]![REPORT LOCATION] <> "ALL" Then

DoCmd.OpenReport stDocName, acViewPreview, , stLinkLocation
End If

If Forms![MAIN MENU]![REPORT LOCATION] = "ALL" Then
DoCmd.OpenReport stDocName, acViewPreview
End If
Exit Sub


Exit_opencpar:
Exit Sub

Err_opencpar:
MsgBox "There are no Records Available"
Resume Exit_opencpar

End Sub
 
THANKS


tkelley via AccessMonster.com said:
Do I misunderstand? You're just trying to click the button and have the code
in

Private Sub opencpar()

execute ... correct?

In the code behind your button:

"Call opencpar"

That's it.


Hello,

I have a button which opens a module to a specific function as the following

DoCmd.OpenModule "ReportFunctions", Me!MODULE

Me!MODULE= a column in a table example "opencpar"

The module opens but in VB to the specific point, I want the module to run
the code..here is the code:

Private Sub opencpar()
On Error GoTo Err_opencpar

Dim stDocName As String
Dim stLinkLocation As String


stDocName = Forms![MAIN MENU]![TYPE OF REPORT]
stLinkLocation = "[LOCATION]=" & "'" & Forms![MAIN MENU]![REPORT
LOCATION] & "'"


If Forms![MAIN MENU]![REPORT LOCATION] <> "ALL" Then

DoCmd.OpenReport stDocName, acViewPreview, , stLinkLocation
End If

If Forms![MAIN MENU]![REPORT LOCATION] = "ALL" Then
DoCmd.OpenReport stDocName, acViewPreview
End If
Exit Sub


Exit_opencpar:
Exit Sub

Err_opencpar:
MsgBox "There are no Records Available"
Resume Exit_opencpar

End Sub
 
I have tried the Call command, but my function changes and I can not seem to
get the Call command to recognize the field...as follows

Private Sub Text2_Click()

Dim stReport As String

stReport = Me![MODULE]

Call stReport

End Sub

I keep getting an error. My stReport changes with every line and would like
to call different code in the module each time.

any help would be appreciated.
 
Thanks, that worked great!!!

tkelley via AccessMonster.com said:
Try this:

http://www.vbaexpress.com/forum/showthread.php?t=22854

Run stReport
I have tried the Call command, but my function changes and I can not seem to
get the Call command to recognize the field...as follows

Private Sub Text2_Click()

Dim stReport As String

stReport = Me![MODULE]

Call stReport

End Sub

I keep getting an error. My stReport changes with every line and would like
to call different code in the module each time.

any help would be appreciated.
 
Back
Top