I am trying to alert a user , by using a message box, to state the various missing data.This works OK except when all data is entered as appropriate I still get the "Warning Message" for missing data! The program therefore does not progress!
As you will have spotted I have used script from other sources as I am not at a level to write my own - hence my inability to solve the problem.
Any help, or pointers, would be greatly appreciated.
Code:
Private Sub Command107_Click()
Dim objPDF As New PDFClass
Dim IngResult As Long
Const PDFENGINE_PDF995 = 5
Dim stFaxNo As String
Dim rptFaxDeal As String
Dim strBroker As String
Dim strTable As String
Dim strError As String
Dim blnError As String
strBroker = Forms!frmMainForm.Text265
strTable = "tblDeals" + strBroker
blnError = False
strError = "Please complete the following:" & vbCrLf
If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text62]) Then
blnError = True
strError = strError & "Vehicle Details" & vbCrLf
ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text62]) Then
blnError = True
End If
If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Miles]) Then
blnError = True
strError = strError & "Mileage" & vbCrLf
ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Miles]) Then
blnError = True
End If
If IsNull([Forms]![frmDeal]![frmDealsSub].Form![RegNo]) Then
blnError = True
strError = strError & "Registration Number" & vbCrLf
ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![RegNo]) Then
blnError = True
End If
If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Year]) Then
blnError = True
strError = strError & "Year of Registration" & vbCrLf
ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Year]) Then
blnError = True
End If
If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text118]) Then
blnError = True
strError = strError & "No. of Owners" & vbCrLf
ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text118]) Then
blnError = True
End If
If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text180]) Then
blnError = True
strError = strError & "Service History" & vbCrLf
ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text180]) Then
blnError = True
End If
If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Import]) Then
blnError = True
strError = strError & "UK car or Import" & vbCrLf
ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Import]) Then
blnError = True
End If
If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Colour]) Then
blnError = True
strError = strError & "Vehicle Colour" & vbCrLf
ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Colour]) Then
blnError = True
End If
If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Interior]) Then
blnError = True
strError = strError & "Interior" & vbCrLf
ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Interior]) Then
blnError = True
End If
If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Damage]) Then
blnError = True
strError = strError & "Condition" & vbCrLf
ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Damage]) Then
blnError = True
End If
If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text250]) Then
blnError = True
strError = strError & "Any Extras" & vbCrLf
ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text250]) Then
blnError = True
End If
If IsNull([Forms]![frmDeal]![frmDealsSub].Form![DealBid]) Then
blnError = True
strError = strError & "Amount Bid" & vbCrLf
ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![DealBid]) Then
blnError = True
End If
If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text148]) Then
blnError = True
strError = strError & "Sellers Comments" & vbCrLf
ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text148]) Then
blnError = True
End If
If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text152]) Then
blnError = True
strError = strError & "Sellers Collection details" & vbCrLf
ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text152]) Then
blnError = True
End If
If IsNull([Forms]![frmDeal]![frmDealsSub].Form![AmountFaxed]) Then
blnError = True
strError = strError & "Selling Brokers Fee" & vbCrLf
ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![AmountFaxed]) Then
blnError = True
End If
If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text150]) Then
blnError = True
strError = strError & "Buyers Comments" & vbCrLf
ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text150]) Then
blnError = True
End If
If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text154]) Then
blnError = True
strError = strError & "Buyers Collection details" & vbCrLf
ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text154]) Then
blnError = True
End If
If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text145]) Then
blnError = True
strError = strError & "Buying Brokers Fee" & vbCrLf
ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text145]) Then
blnError = True
End If
If blnError = True Then
Cancel = True
MsgBox strError, vbOKOnly + vbCritical, "Stop!"
Exit Sub
End If
MissingBuyer:
Data1 = MsgBox("Buying Dealers details must be completed to continue", vbOKCancel, "Missing data!")
If Data1 = vbCancel Then Exit Sub
If Data1 = vbOK Then Me.Text36.SetFocus
Me.Text36.BackColor = 8454143
Exit Sub
Continue:
If IsNull(Me.Text36) Or IsNull(cboBuyingDealer) Or cboBuyingContact = "" Or Text188 = "" Or txtFaxNo = "" Then GoTo MissingBuyer Else
stFaxNo = Me.DealNo
rptFaxDeal = "rptFaxDealFax"
ViewReport = "C:\PDF995\" & stFaxNo + ".pdf"
SQLtext = "INSERT INTO " & strTable & " (BuyingDealer)SELECT Text97 WHERE FROM " & strTable & "(((" & strTable & ".Ticket)=[Forms]![frmDeal].[Text178]));"
SQLtext1 = "UPDATE " & strTable & " SET " & strTable & ".BuyingDealer = [Forms]![frmDeal].[text97]WHERE (((" & strTable & ".Ticket)=[Forms]![frmDeal].[Text178]));"
DoCmd.RunSQL (SQLtext1)
With objPDF
.PDFEngine = PDFENGINE_PDF995
.reportname = rptFaxDeal
.outputfile = "C:\PDF995\" & stFaxNo + ".pdf"
.PrintImage
IngResult = .Result
End With
Set objPDF = Nothing
DoCmd.OpenReport "rptFaxDealFaxSell", acPreview
Reports!rptFaxDealFaxSell.Caption = stFaxNo + "-S" + ".pdf"
DoCmd.OpenReport "rptFaxDealFaxBuy", acPreview
Reports!rptFaxDealFaxBuy.Caption = stFaxNo + "-B" + ".pdf"
Me.comSendFax.Enabled = True
End Sub
Any help, or pointers, would be greatly appreciated.
Comment