Dear friends,
I've tried to create a message box with dlookup, to check for empty sub forms, before exporting to pdf.
The results i get is only 1 line in the message with only one section.
I've tried it with 3 sections (with and without data) but i get always the message for section 1 (containing data or not), like its always empty.
There's something wrong in case statement! :banghead:
Private Sub Command56_Click()
On Error GoTo Err_Command56_click
Dim MsgResults As String
Dim MsgResultsContent As String
Dim CheckSection As Integer
MsgResults = "Cannot export the file, the following section(s) don't contain data: " & vbCrLf
MsgResultsContent=""
Select Case CheckSection
Case IsNull(DLookup("[product_id]", "tblsection01", "product_ID =" & Me.product_ID))
MsgResultsContent = MsgResultsContent & "- Section 1" & vbCrLf
Case IsNull(DLookup("[product_id]", "tblsection02", "product_ID =" & Me.product_ID))
MsgResultsContent = MsgResultsContent & "- Section 2" & vbCrLf
Case IsNull(DLookup("[product_id]", "tblsection03", "product_ID =" & Me.product_ID))
MsgResultsContent = MsgResultsContent & "- Section 3" & vbCrLf
Case Else
MsgResults = "OK"
End Select
MsgBox MsgResults & MsgResultsContent
Exit_Err_Command56_click:
Exit Sub
Err_Command56_click:
MsgBox "Error, please inform administrator: (" & Err.Number & ") " & Err.Description, vbCritical
Resume Exit_Err_Command56_click
I've tried to create a message box with dlookup, to check for empty sub forms, before exporting to pdf.
The results i get is only 1 line in the message with only one section.
I've tried it with 3 sections (with and without data) but i get always the message for section 1 (containing data or not), like its always empty.
There's something wrong in case statement! :banghead:
Private Sub Command56_Click()
On Error GoTo Err_Command56_click
Dim MsgResults As String
Dim MsgResultsContent As String
Dim CheckSection As Integer
MsgResults = "Cannot export the file, the following section(s) don't contain data: " & vbCrLf
MsgResultsContent=""
Select Case CheckSection
Case IsNull(DLookup("[product_id]", "tblsection01", "product_ID =" & Me.product_ID))
MsgResultsContent = MsgResultsContent & "- Section 1" & vbCrLf
Case IsNull(DLookup("[product_id]", "tblsection02", "product_ID =" & Me.product_ID))
MsgResultsContent = MsgResultsContent & "- Section 2" & vbCrLf
Case IsNull(DLookup("[product_id]", "tblsection03", "product_ID =" & Me.product_ID))
MsgResultsContent = MsgResultsContent & "- Section 3" & vbCrLf
Case Else
MsgResults = "OK"
End Select
MsgBox MsgResults & MsgResultsContent
Exit_Err_Command56_click:
Exit Sub
Err_Command56_click:
MsgBox "Error, please inform administrator: (" & Err.Number & ") " & Err.Description, vbCritical
Resume Exit_Err_Command56_click