DoCmd.OpenModule question

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
 
T

tkelley via AccessMonster.com

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
 
R

Ryis

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
 
R

Ryis

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.
 
T

tkelley via AccessMonster.com

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.
 
R

Ryis

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top