[FONT=Tahoma][SIZE=1][FONT=Tahoma][SIZE=1]
[LEFT]Sub MakeReport()
On Error GoTo Err_MakeReport[/LEFT]
[/SIZE][/FONT][/SIZE][/FONT][FONT=Tahoma][SIZE=1][COLOR=#008100][FONT=Tahoma][SIZE=1][COLOR=#008100][FONT=Tahoma][SIZE=1][COLOR=#008100][LEFT]'Open report in design view to write properties to objects[/LEFT]
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Tahoma][SIZE=1][FONT=Tahoma][SIZE=1][LEFT]DoCmd.OpenReport "rptCustom", acDesign[/LEFT]
[/SIZE][/FONT][/SIZE][/FONT][FONT=Tahoma][SIZE=1][COLOR=#008100][FONT=Tahoma][SIZE=1][COLOR=#008100][FONT=Tahoma][SIZE=1][COLOR=#008100][LEFT]'Read combo box selections and use subroutine to set report object properties[/LEFT]
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Tahoma][SIZE=1][FONT=Tahoma][SIZE=1][LEFT][COLOR=red]SetReportControls Forms!frmChooseFields.cboField1.Value, Reports!rptCustom.lblField1, Reports!rptCustom.tbField1[/COLOR]
SetReportControls Forms!frmChooseFields.cboField2.Value, Reports!rptCustom.lblField2, Reports!rptCustom.tbField2
SetReportControls Forms!frmChooseFields.cboField3.Value, Reports!rptCustom.lblField3, Reports!rptCustom.tbField3
SetReportControls Forms!frmChooseFields.cboField4.Value, Reports!rptCustom.lblField4, Reports!rptCustom.tbField4[/LEFT]
[/SIZE][/FONT][/SIZE][/FONT][FONT=Tahoma][SIZE=1][COLOR=#008100][FONT=Tahoma][SIZE=1][COLOR=#008100][FONT=Tahoma][SIZE=1][COLOR=#008100][LEFT]'Close design view without prompting to save changes[/LEFT]
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Tahoma][SIZE=1][FONT=Tahoma][SIZE=1][LEFT]DoCmd.Close acReport, "rptCustom", acSaveYes[/LEFT]
[/SIZE][/FONT][/SIZE][/FONT][FONT=Tahoma][SIZE=1][COLOR=#008100][FONT=Tahoma][SIZE=1][COLOR=#008100][FONT=Tahoma][SIZE=1][COLOR=#008100][LEFT]'Open finished report in preview view[/LEFT]
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Tahoma][SIZE=1][FONT=Tahoma][SIZE=1][LEFT]DoCmd.OpenReport "rptCustom", acPreview
Exit_MakeReport:
Exit Sub
Err_MakeReport:
MsgBox Err.Description
Resume Exit_MakeReport
End Sub
Sub SetReportControls(varFieldName As Variant, conLabel As Control, conTextBox As Control)[/LEFT]
[/SIZE][/FONT][/SIZE][/FONT][FONT=Tahoma][SIZE=1][COLOR=#008100][FONT=Tahoma][SIZE=1][COLOR=#008100][FONT=Tahoma][SIZE=1][COLOR=#008100][LEFT]'Check if selection is 'null'[/LEFT]
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Tahoma][SIZE=1][FONT=Tahoma][SIZE=1][LEFT]If IsNull(varFieldName) Then [/SIZE][/FONT][/SIZE][/FONT][FONT=Tahoma][SIZE=1][COLOR=#008100][FONT=Tahoma][SIZE=1][COLOR=#008100][FONT=Tahoma][SIZE=1][COLOR=#008100]'Blank out the relevant objects[/LEFT]
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Tahoma][SIZE=1][FONT=Tahoma][SIZE=1][LEFT]conLabel.Caption = " "
conTextBox.ControlSource = ""
Else [/SIZE][/FONT][/SIZE][/FONT][FONT=Tahoma][SIZE=1][COLOR=#008100][FONT=Tahoma][SIZE=1][COLOR=#008100][FONT=Tahoma][SIZE=1][COLOR=#008100]'Write the selected field name to the appropriate objects[/LEFT]
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Tahoma][SIZE=1][FONT=Tahoma][SIZE=1][LEFT]conLabel.Caption = varFieldName
conTextBox.ControlSource = varFieldName
End If[/LEFT]
End Sub
[/SIZE][/FONT][/SIZE][/FONT]