Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / October 2007

Tip: Looking for answers? Try searching our database.

designation of report used with control variable ('er something)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
magmike - 30 Oct 2007 05:49 GMT
What I am trying to do, is create multiple reports (or I should say,
prefabbed letters). Then, using a dropdown box on a "SendLetters"
form, allow the user to select the desired letter to send, click a
button, and then the corresponding "letter" or report open with the
records data where it should be, on the report or letter that was
selected in the "letter" or report drop down box.

Is this making any sense?

Thanks in advance for your help!

magmike
NevilleT - 30 Oct 2007 07:35 GMT
Hi
Not too complicated.  You will need to use some VBA to select the report.  
Suggest you first create a table with the something like the following
tblLetters
LetterNo - Autonumber - Primary Key
LetterName - Text
ReportName - Text
SeqNo - Integer

Create a combo e.g. (cmbLetter) that displays the LetterName and sort it in
SeqNo.  This allows you to create your own sort sequence.  Put the most
common ones at the top.

In the VBA for the button onClick event, you can use something like this.  I
prefer to use a sub in a generic module to open reports.  Saves creating
error trapping etc.

Private Sub Report_Button_Click()
  dim strReportName as String

  strReportName = Forms!frmReportSelector!cmbLetter

'   DoCmd.RunCommand acCmdSaveRecord  ' Save the record.  Not needed if the
button is not on the form you use to enter data
   
   subOpenReports strReportName
End Sub

Put this in a module.  I have one called modGeneric where I have lots of
these generic functions and subs.

Public Sub subOpenReports(strReportName As String, Optional strQuery As
String, Optional strWhere As String, Optional strOpenArgs As String)
' This function is used in the Click event of command buttons that opens
reports

   On Error GoTo Error_subOpenReports

   ' Open specified form.
   DoCmd.OpenReport strReportName, acPreview, strQuery, strWhere
   
Exit_subOpenReports:
   On Error GoTo 0
   Exit Sub

Error_subOpenReports:

   MsgBox "An unexpected situation arose in your program." & funCrLf & _
          "Please write down the following details:" & funCrLf & funCrLf & _
          "Module Name: modGeneric" & funCrLf & _
          "Type: Module" & funCrLf & _
          "Calling Procedure: subOpenReports" & funCrLf & _
          "Error Number: " & Err.Number & funCrLf & _
          "Error Descritption: " & Err.Description
         
   Resume Exit_subOpenReports

End Sub

 



> What I am trying to do, is create multiple reports (or I should say,
> prefabbed letters). Then, using a dropdown box on a "SendLetters"
[quoted text clipped - 8 lines]
>
> magmike
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.