M
M. Bakker
Hi,
I have a database for projects. Letters and faxes are related to these projects, and shown in a subform. Above it –in the main form-, I’ve made a combobox (cboProjects). When nothing is selected here, all letters and faxes are shown in the subform. When I select a project, only the letters related to that project are shown.
Next to the combobox I’ve made a button to get the info shown in the subform to a report. This does’nt work.
My knowledge of VB is very poor, who can help? I’ve added the code that has to be modified below.
Thanks!
M. Bakker
'+++ start code:
Private Sub PrintReport_Click()
On Error GoTo Err_PrintReport_Click
Dim stDocName As String
Dim strSQL As String
If Len(Me!cboProjects) Then
strSQL = "SELECT * FROM [qryLetters] " & _
"WHERE [UitvrId]=" & Me!cboProjects
Else
strSQL = "SELECT * FROM [qryLetters]"
End If
stDocName = "rpProjectRelatedLetters"
DoCmd.OpenReport stDocName, acPreview
.RecordSource = strSQL
.Form.Requery
End With
' +++ end code
I have a database for projects. Letters and faxes are related to these projects, and shown in a subform. Above it –in the main form-, I’ve made a combobox (cboProjects). When nothing is selected here, all letters and faxes are shown in the subform. When I select a project, only the letters related to that project are shown.
Next to the combobox I’ve made a button to get the info shown in the subform to a report. This does’nt work.
My knowledge of VB is very poor, who can help? I’ve added the code that has to be modified below.
Thanks!
M. Bakker
'+++ start code:
Private Sub PrintReport_Click()
On Error GoTo Err_PrintReport_Click
Dim stDocName As String
Dim strSQL As String
If Len(Me!cboProjects) Then
strSQL = "SELECT * FROM [qryLetters] " & _
"WHERE [UitvrId]=" & Me!cboProjects
Else
strSQL = "SELECT * FROM [qryLetters]"
End If
stDocName = "rpProjectRelatedLetters"
DoCmd.OpenReport stDocName, acPreview
.RecordSource = strSQL
.Form.Requery
End With
' +++ end code