Paradox 
; Call FormString.FSL
method Run_Form(const FormString String)
var
  TempForm      Form
endVar
     ; Add/re-define aliases
  if not Add_Aliases() then return endif
  TempForm.open(FormString)
  hide()            ; Hides the calling form
  TempForm.wait()   ; Wait for TempForm to be closed
;  TempForm.close() ; Required in version 4.5,
                    ;    causes an error in version 5.0
  show()            ; Re-show this form
  bringToTop()      ; And put it on top
endmethod
 Reports 
method Run_Report_Query(const ReportString String,
                        const QueryString  String,
                        const Orientation  LongInt)
; Assign aliases and call ReportString.RSL
var
  TempReport      Report
  openInfo        ReportPrintInfo ; It does not matter if this is
                                  ; ReportPrintInfo of ReportOpenInfo
                                  ; TempReport.open() works either way
endVar
     ; Add/re-define some aliases
  if not Add_Aliases() then msginfo("","help") return endif
  Report_Footer()
  openInfo.name = ReportString
  openInfo.MasterTable = QueryString
     ; orient	SmallInt      Page orientation. Landscape or Portrait
; openInfo.orient = PrintLandscape  ; This does not work with view
  switch 
    case Report_Action_UI_Field = "Print":
      TempReport.print(openInfo)
    case Report_Action_UI_Field = "View" :
      TempReport.open(openInfo) 
      TempReport.DesignModified = false 
      TempReport.menuAction(MenuPropertiesZoomFitWidth)
      hide()
      TempReport.wait()
;     TempReport.close() ; Required in version 4.5, 
                         ;    causes an error in version 5.0
      show()
      bringToTop()
    case Report_Action_UI_Field = "Edit" :
      TempReport.load(ReportString) ; can not change the query
      TempReport.menuAction(MenuPropertiesZoomFitWidth)
      hide()
      TempReport.wait()
      show()
      bringToTop()
  endswitch
  
endmethod
 Report Footers 
Well, to solve that problem, I allow the system to generate a footer which identifies enough information to reproduce the report. The data is passed using EnvironmentStrings which are read using a calculated field.
method Report_Footer()
var 
  tt  String
endvar
 tt = globalParameters["Document ID"] + " " +  
                    Document_UI_Field.Get_Document_Name()
 tt = tt + "    Query = "  + Query_Selection_UI_Field.value
 tt = tt +  ",  Report = " + Report_Selection_UI_Field
 tt = tt +  ",  Printed via " + getFileName()
 ;tt.view()  ; For debug only
  ; Pass the footer string to the report
  ; The report uses a calculated field to retrieve the value
 writeEnvironmentString("Temp Report Footer", tt)
endmethod
DoCmd.OpenForm formname[, view][, filtername][, wherecondition] _
                       [, datamode][, windowmode][, openargs]
DoCmd.OpenReport reportname[, view][, filtername][, wherecondition]
| formname | Just a string | 
| view | Form view (default) or design view | 
| filtername | The name of a query (string) | 
| wherecondition | An SQL where clause without the word where (string)
   Does not work with forms based on aggregate queries (queries containing "Group by") Does work with reports based on aggregate queries  | 
| datamode | Add, Edit, ReadOnly, FormDefault | 
| windowmode | Icon, Hidden, Dialog, Normal | 
| openargs | This is just a string - the form can read it via
     
  tempString = Forms![Form Name].OpenArgs
  tempString = Me.OpenArgs
     
 | 
For OpenReport to work, the report MUST BE CLOSED. If the report is open, subsequent OpenReport statements actually do nothing.
Both of these Where clauses will work. (Notice the quote marks.)
"Distribution=""CP""" "Distribution='CP'"
 
 Opening Forms Based on Aggregate Queries 
I have a situation where I want the calling form to modify the Where clause of an Aggregate query. However, it appears that the query is run before the wherecondition is applied, thus producing the wrong results. The solution is to
  ' Calling command
  DoCmd.OpenForm "Form Being Called", OpenArgs:=SomeValue
 ' in "Form Being Called"
Private Sub Form_Open(Cancel As Integer)
Dim query, arg
  arg = Me.OpenArgs
  query = "SELECT Sum(Int([Quantity])) AS TotalQuantity, " _
        & "DeliveryOrderLineItems.[DO Part Name], " _
        & "DeliveryOrderLineItems.[Unit Sale Price] " _
        & "From DeliveryOrderLineItems "
  query = query _
        & "WHERE (((DeliveryOrderLineItems.[Shipment ID]) " _
        & "Like '" & arg & "*' And Not " _
        & "(DeliveryOrderLineItems.[Shipment ID]) = '" & arg & "')) "
  query = query _
        & "GROUP BY DeliveryOrderLineItems.[DO Part Name], " _
        & "DeliveryOrderLineItems.[Unit Sale Price];"
 Me.RecordSource = query
 Passing a Parameter Example 
  ' On the button that opens the form
  DoCmd.OpenForm "FormName", , , , , , "Passed Parameter"
  ' In the form - "FormName"
Sub Form_Open(Cancel As Integer)
  If Not IsNull(Me.OpenArgs) Then
    Dim strEmployeeName As String
    strEmployeeName = Me.OpenArgs
    Dim RS As Recordset
    Set RS = Me.RecordsetClone
    RS.FindFirst "LastName = '" & strEmployeeName & "'"
    If Not RS.NoMatch Then
      Me.Bookmark = RS.Bookmark
    End If
  End If
End Sub
 
When an assignment fails in Form_Open
try Form_Load.
 
 Changing the Form View 
Const conFormView = 1
Const conDataSheet = 2
  ' Determine which view is currently selected
If CurrentView = conDataSheet Then
    ...
End If
  ' Toggle this form between views
DoCmd.RunCommand acCmdSubformDatasheet
  ' Specify the SubForm first
FirmData___SubForm.SetFocus
DoCmd.RunCommand acCmdSubformDatasheet
There is a problem adding this code to a double click
event of a sub-form
On Error Resume Next DoCmd.RunCommand acCmdSubformDatasheet
 
 Custom Dialog Boxes 
 Delphi 5.0 - Visual Basic 6.0 - Java