473,594 Members | 2,655 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Validating data entry (Access 2000)

62 New Member
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!

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command107_Click()
  2. Dim objPDF As New PDFClass
  3. Dim IngResult As Long
  4. Const PDFENGINE_PDF995 = 5
  5. Dim stFaxNo As String
  6. Dim rptFaxDeal As String
  7. Dim strBroker As String
  8. Dim strTable As String
  9. Dim strError As String
  10. Dim blnError As String
  11.  
  12. strBroker = Forms!frmMainForm.Text265
  13. strTable = "tblDeals" + strBroker
  14. blnError = False
  15.  
  16. strError = "Please complete the following:" & vbCrLf
  17.  
  18.             If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text62]) Then
  19.                   blnError = True
  20.                       strError = strError & "Vehicle Details" & vbCrLf
  21.  
  22.               ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text62]) Then
  23.                     blnError = True
  24.                         End If
  25.             If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Miles]) Then
  26.                   blnError = True
  27.                       strError = strError & "Mileage" & vbCrLf
  28.  
  29.               ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Miles]) Then
  30.                     blnError = True
  31.                         End If
  32.              If IsNull([Forms]![frmDeal]![frmDealsSub].Form![RegNo]) Then
  33.                   blnError = True
  34.                       strError = strError & "Registration Number" & vbCrLf
  35.  
  36.               ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![RegNo]) Then
  37.                     blnError = True
  38.                         End If
  39.             If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Year]) Then
  40.                   blnError = True
  41.                       strError = strError & "Year of Registration" & vbCrLf
  42.  
  43.               ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Year]) Then
  44.                     blnError = True
  45.                         End If
  46.               If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text118]) Then
  47.                   blnError = True
  48.                       strError = strError & "No. of Owners" & vbCrLf
  49.  
  50.               ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text118]) Then
  51.                     blnError = True
  52.                         End If
  53.               If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text180]) Then
  54.                   blnError = True
  55.                       strError = strError & "Service History" & vbCrLf
  56.  
  57.               ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text180]) Then
  58.                     blnError = True
  59.                         End If
  60.                  If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Import]) Then
  61.                   blnError = True
  62.                       strError = strError & "UK car or Import" & vbCrLf
  63.  
  64.               ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Import]) Then
  65.                     blnError = True
  66.                         End If
  67.                If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Colour]) Then
  68.                   blnError = True
  69.                       strError = strError & "Vehicle Colour" & vbCrLf
  70.  
  71.               ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Colour]) Then
  72.                     blnError = True
  73.                         End If
  74.                 If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Interior]) Then
  75.                   blnError = True
  76.                       strError = strError & "Interior" & vbCrLf
  77.  
  78.               ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Interior]) Then
  79.                     blnError = True
  80.                         End If
  81.  
  82.                  If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Damage]) Then
  83.                   blnError = True
  84.                       strError = strError & "Condition" & vbCrLf
  85.  
  86.               ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Damage]) Then
  87.                     blnError = True
  88.                         End If
  89.  
  90.                  If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text250]) Then
  91.                   blnError = True
  92.                       strError = strError & "Any Extras" & vbCrLf
  93.  
  94.               ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text250]) Then
  95.                     blnError = True
  96.                         End If
  97.  
  98.                  If IsNull([Forms]![frmDeal]![frmDealsSub].Form![DealBid]) Then
  99.                   blnError = True
  100.                       strError = strError & "Amount Bid" & vbCrLf
  101.  
  102.               ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![DealBid]) Then
  103.                     blnError = True
  104.                         End If
  105.  
  106.                     If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text148]) Then
  107.                   blnError = True
  108.                       strError = strError & "Sellers Comments" & vbCrLf
  109.  
  110.               ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text148]) Then
  111.                     blnError = True
  112.                         End If
  113.                  If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text152]) Then
  114.                   blnError = True
  115.                       strError = strError & "Sellers Collection details" & vbCrLf
  116.  
  117.               ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text152]) Then
  118.                     blnError = True
  119.                         End If
  120.  
  121.                     If IsNull([Forms]![frmDeal]![frmDealsSub].Form![AmountFaxed]) Then
  122.                   blnError = True
  123.                       strError = strError & "Selling Brokers Fee" & vbCrLf
  124.  
  125.               ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![AmountFaxed]) Then
  126.                     blnError = True
  127.                         End If
  128.  
  129.                    If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text150]) Then
  130.                   blnError = True
  131.                       strError = strError & "Buyers Comments" & vbCrLf
  132.  
  133.               ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text150]) Then
  134.                     blnError = True
  135.                         End If
  136.  
  137.                    If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text154]) Then
  138.                   blnError = True
  139.                       strError = strError & "Buyers Collection details" & vbCrLf
  140.  
  141.               ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text154]) Then
  142.                     blnError = True
  143.                         End If
  144.  
  145.                    If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text145]) Then
  146.                   blnError = True
  147.                       strError = strError & "Buying Brokers Fee" & vbCrLf
  148.  
  149.               ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text145]) Then
  150.                     blnError = True
  151.                         End If
  152.  
  153.            If blnError = True Then
  154.                 Cancel = True
  155.                     MsgBox strError, vbOKOnly + vbCritical, "Stop!"
  156.                          Exit Sub
  157.               End If
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165. MissingBuyer:
  166. Data1 = MsgBox("Buying Dealers details must be completed to continue", vbOKCancel, "Missing data!")
  167. If Data1 = vbCancel Then Exit Sub
  168. If Data1 = vbOK Then Me.Text36.SetFocus
  169. Me.Text36.BackColor = 8454143
  170. Exit Sub
  171.  
  172.  
  173. Continue:
  174. If IsNull(Me.Text36) Or IsNull(cboBuyingDealer) Or cboBuyingContact = "" Or Text188 = "" Or txtFaxNo = "" Then GoTo MissingBuyer Else
  175. stFaxNo = Me.DealNo
  176. rptFaxDeal = "rptFaxDealFax"
  177. ViewReport = "C:\PDF995\" & stFaxNo + ".pdf"
  178. SQLtext = "INSERT INTO " & strTable & " (BuyingDealer)SELECT Text97  WHERE FROM " & strTable & "(((" & strTable & ".Ticket)=[Forms]![frmDeal].[Text178]));"
  179. SQLtext1 = "UPDATE " & strTable & " SET " & strTable & ".BuyingDealer = [Forms]![frmDeal].[text97]WHERE (((" & strTable & ".Ticket)=[Forms]![frmDeal].[Text178]));"
  180.  
  181. DoCmd.RunSQL (SQLtext1)
  182. With objPDF
  183.     .PDFEngine = PDFENGINE_PDF995
  184.     .reportname = rptFaxDeal
  185.     .outputfile = "C:\PDF995\" & stFaxNo + ".pdf"
  186.     .PrintImage
  187.     IngResult = .Result
  188.  
  189.     End With
  190.  
  191.     Set objPDF = Nothing
  192.     DoCmd.OpenReport "rptFaxDealFaxSell", acPreview
  193.     Reports!rptFaxDealFaxSell.Caption = stFaxNo + "-S" + ".pdf"
  194.       DoCmd.OpenReport "rptFaxDealFaxBuy", acPreview
  195.     Reports!rptFaxDealFaxBuy.Caption = stFaxNo + "-B" + ".pdf"
  196.       Me.comSendFax.Enabled = True
  197.  
  198.  
  199. End Sub
  200.  
  201.  
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.
Nov 2 '07 #1
13 1891
ADezii
8,834 Recognized Expert Expert
boliches, I'm not speaking for the rest of the Moderators/Experts in this Forum, but personally I will not attempt to decipher 200 lines of code unles it is properly Formatted and Tagged. If you can get the code in a more readable and tagged format, I will be more than happy to have a look at it.
Nov 2 '07 #2
boliches
62 New Member
boliches, I'm not speaking for the rest of the Moderators/Experts in this Forum, but personally I will not attempt to decipher 200 lines of code unles it is properly Formatted and Tagged. If you can get the code in a more readable and tagged format, I will be more than happy to have a look at it.

I dont fully understand what you want, but I have cut it down to a manageable size (I hope)
Expand|Select|Wrap|Line Numbers
  1. blnError = False
  2.  
  3. strError = "Please complete the following:" & vbCrLf
  4.  
  5.             If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text62]) Then
  6.                   blnError = True
  7.                       strError = strError & "Vehicle Details" & vbCrLf
  8.  
  9.               ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text62]) Then
  10.                     blnError = True
  11.                         End If
  12.             If blnError = True Then
  13.                 Cancel = True
  14.                     MsgBox strError, vbOKOnly + vbCritical, "Stop!"
  15.                          Exit Sub
  16.               End If
  17.  
The problem is the MsgBox is still shown even when all relevant Text Boxes are filled
Nov 3 '07 #3
ADezii
8,834 Recognized Expert Expert
I dont fully understand what you want, but I have cut it down to a manageable size (I hope)
Expand|Select|Wrap|Line Numbers
  1. blnError = False
  2.  
  3. strError = "Please complete the following:" & vbCrLf
  4.  
  5.             If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text62]) Then
  6.                   blnError = True
  7.                       strError = strError & "Vehicle Details" & vbCrLf
  8.  
  9.               ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text62]) Then
  10.                     blnError = True
  11.                         End If
  12.             If blnError = True Then
  13.                 Cancel = True
  14.                     MsgBox strError, vbOKOnly + vbCritical, "Stop!"
  15.                          Exit Sub
  16.               End If
  17.  
The problem is the MsgBox is still shown even when all relevant Text Boxes are filled
This is what I was referring to, I'll look at it as soon as I get a chance.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command107_Click()
  2. Dim objPDF As New PDFClass
  3. Dim IngResult As Long
  4. Const PDFENGINE_PDF995 = 5
  5. Dim stFaxNo As String
  6. Dim rptFaxDeal As String
  7. Dim strBroker As String
  8. Dim strTable As String
  9. Dim strError As String
  10. Dim blnError As String
  11.  
  12. strBroker = Forms!frmMainForm.Text265
  13. strTable = "tblDeals" + strBroker
  14. blnError = False
  15.  
  16. strError = "Please complete the following:" & vbCrLf
  17.  
  18. If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text62]) Then
  19.   blnError = True
  20.   trError = strError & "Vehicle Details" & vbCrLf
  21. ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text62]) Then
  22.   blnError = True
  23. End If
  24.  
  25. If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Miles]) Then
  26.   blnError = True
  27.   strError = strError & "Mileage" & vbCrLf
  28. ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Miles]) Then
  29.   blnError = True
  30. End If
  31.  
  32. If IsNull([Forms]![frmDeal]![frmDealsSub].Form![RegNo]) Then
  33.   blnError = True
  34.   strError = strError & "Registration Number" & vbCrLf
  35. ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![RegNo]) Then
  36.   blnError = True
  37. End If
  38.  
  39. If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Year]) Then
  40.   blnError = True
  41.   strError = strError & "Year of Registration" & vbCrLf
  42. ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Year]) Then
  43.   blnError = True
  44. End If
  45.  
  46. If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text118]) Then
  47.   blnError = True
  48.   strError = strError & "No. of Owners" & vbCrLf
  49. ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text118]) Then
  50.   blnError = True
  51. End If
  52.  
  53. If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text180]) Then
  54.   blnError = True
  55.   strError = strError & "Service History" & vbCrLf
  56. ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text180]) Then
  57.   blnError = True
  58. End If
  59.  
  60. If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Import]) Then
  61.   blnError = True
  62.   strError = strError & "UK car or Import" & vbCrLf
  63. ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Import]) Then
  64.   blnError = True
  65. End If
  66.  
  67. If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Colour]) Then
  68.   blnError = True
  69.   strError = strError & "Vehicle Colour" & vbCrLf
  70. ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Colour]) Then
  71.   blnError = True
  72. End If
  73.  
  74. If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Interior]) Then
  75.   blnError = True
  76.   strError = strError & "Interior" & vbCrLf
  77. ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Interior]) Then
  78.   blnError = True
  79. End If
  80.  
  81. If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Damage]) Then
  82.   blnError = True
  83.   strError = strError & "Condition" & vbCrLf
  84. ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Damage]) Then
  85.   blnError = True
  86. End If
  87.  
  88. If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text250]) Then
  89.   blnError = True
  90.   strError = strError & "Any Extras" & vbCrLf
  91. ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text250]) Then
  92.   blnError = True
  93. End If
  94.  
  95. If IsNull([Forms]![frmDeal]![frmDealsSub].Form![DealBid]) Then
  96.   blnError = True
  97.   strError = strError & "Amount Bid" & vbCrLf
  98. ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![DealBid]) Then
  99.   blnError = True
  100. End If
  101.  
  102. If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text148]) Then
  103.   blnError = True
  104.   strError = strError & "Sellers Comments" & vbCrLf
  105. ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text148]) Then
  106.   blnError = True
  107. End If
  108.  
  109. If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text152]) Then
  110.   blnError = True
  111.   strError = strError & "Sellers Collection details" & vbCrLf
  112. ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text152]) Then
  113.   blnError = True
  114. End If
  115.  
  116. If IsNull([Forms]![frmDeal]![frmDealsSub].Form![AmountFaxed]) Then
  117.   blnError = True
  118.   strError = strError & "Selling Brokers Fee" & vbCrLf
  119. ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![AmountFaxed]) Then
  120.   blnError = True
  121. End If
  122.  
  123. If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text150]) Then
  124.   blnError = True
  125.   strError = strError & "Buyers Comments" & vbCrLf
  126. ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text150]) Then
  127.   blnError = True
  128. End If
  129.  
  130. If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text154]) Then
  131.   blnError = True
  132.   strError = strError & "Buyers Collection details" & vbCrLf
  133. ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text154]) Then
  134.   blnError = True
  135. End If
  136.  
  137. If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text145]) Then
  138.   blnError = True
  139.   strError = strError & "Buying Brokers Fee" & vbCrLf
  140. ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text145]) Then
  141.   blnError = True
  142. End If
  143.  
  144. If blnError = True Then
  145.   Cancel = True
  146.   MsgBox strError, vbOKOnly + vbCritical, "Stop!"
  147.     Exit Sub
  148. End If
  149.  
  150. MissingBuyer:
  151. Data1 = MsgBox("Buying Dealers details must be completed to continue", vbOKCancel, "Missing data!")
  152. If Data1 = vbCancel Then Exit Sub
  153. If Data1 = vbOK Then Me.Text36.SetFocus
  154.   Me.Text36.BackColor = 8454143
  155.     Exit Sub
  156.  
  157.  
  158. Continue:
  159. If IsNull(Me.Text36) Or IsNull(cboBuyingDealer) Or cboBuyingContact = "" Or Text188 = "" Or txtFaxNo = "" Then
  160.   GoTo MissingBuyer
  161. Else
  162.   stFaxNo = Me.DealNo
  163.   rptFaxDeal = "rptFaxDealFax"
  164.   ViewReport = "C:\PDF995\" & stFaxNo + ".pdf"
  165.   SQLtext = "INSERT INTO " & strTable & " (BuyingDealer)SELECT Text97  WHERE FROM " & strTable & "(((" & strTable & ".Ticket)=[Forms]![frmDeal].[Text178]));"
  166.   SQLtext1 = "UPDATE " & strTable & " SET " & strTable & ".BuyingDealer = [Forms]![frmDeal].[text97]WHERE (((" & strTable & ".Ticket)=[Forms]![frmDeal].[Text178]));"
  167.  
  168.   DoCmd.RunSQL (SQLtext1)
  169.  
  170. With objPDF
  171.   .PDFEngine = PDFENGINE_PDF995
  172.   .reportname = rptFaxDeal
  173.   .outputfile = "C:\PDF995\" & stFaxNo + ".pdf"
  174.   .PrintImage
  175.     IngResult = .Result
  176. End With
  177.  
  178. Set objPDF = Nothing
  179.  
  180. DoCmd.OpenReport "rptFaxDealFaxSell", acPreview
  181. Reports!rptFaxDealFaxSell.Caption = stFaxNo + "-S" + ".pdf"
  182. DoCmd.OpenReport "rptFaxDealFaxBuy", acPreview
  183. Reports!rptFaxDealFaxBuy.Caption = stFaxNo + "-B" + ".pdf"
  184.   Me.comSendFax.Enabled = True
  185. End Sub
NOTE: Is there any reason why the Validation is not done in the BeforeUpdate() Event of frmDeal?
Nov 3 '07 #4
ADezii
8,834 Recognized Expert Expert
I dont fully understand what you want, but I have cut it down to a manageable size (I hope)
Expand|Select|Wrap|Line Numbers
  1. blnError = False
  2.  
  3. strError = "Please complete the following:" & vbCrLf
  4.  
  5.             If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text62]) Then
  6.                   blnError = True
  7.                       strError = strError & "Vehicle Details" & vbCrLf
  8.  
  9.               ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text62]) Then
  10.                     blnError = True
  11.                         End If
  12.             If blnError = True Then
  13.                 Cancel = True
  14.                     MsgBox strError, vbOKOnly + vbCritical, "Stop!"
  15.                          Exit Sub
  16.               End If
  17.  
The problem is the MsgBox is still shown even when all relevant Text Boxes are filled
It appears that with your current logic, blnError will never evaluate to False. In the If...End If Statements, it seems to me that the ElseIf Clauses (Not IsNull()) should set the value of blnError to False, and the code syntax can be shortened. A couple of examples will illlustrate my point:
Expand|Select|Wrap|Line Numbers
  1. If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text62]) Then
  2.   blnError = True
  3.   trError = strError & "Vehicle Details" & vbCrLf
  4. ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text62]) Then
  5.   blnError = True
  6. End If
  7.  
  8. If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Miles]) Then
  9.   blnError = True
  10.   strError = strError & "Mileage" & vbCrLf
  11. ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Miles]) Then
  12.   blnError = True
  13. End If
try
Expand|Select|Wrap|Line Numbers
  1. 'It's either Not Null or Null
  2. If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text62]) Then
  3.   blnError = True
  4.   trError = strError & "Vehicle Details" & vbCrLf
  5. Else
  6.   blnError = False
  7. End If
  8.  
  9. 'It's either Not Null or Null           
  10. If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Miles]) Then
  11.   blnError = True
  12.   strError = strError & "Mileage" & vbCrLf
  13. Else
  14.   blnError = False
  15. End If
  16.  
Nov 3 '07 #5
boliches
62 New Member
It appears that with your current logic, blnError will never evaluate to False. In the If...End If Statements, it seems to me that the ElseIf Clauses (Not IsNull()) should set the value of blnError to False, and the code syntax can be shortened. A couple of examples will illlustrate my point:
Expand|Select|Wrap|Line Numbers
  1. If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text62]) Then
  2.   blnError = True
  3.   trError = strError & "Vehicle Details" & vbCrLf
  4. ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text62]) Then
  5.   blnError = True
  6. End If
  7.  
  8. If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Miles]) Then
  9.   blnError = True
  10.   strError = strError & "Mileage" & vbCrLf
  11. ElseIf Not IsNull([Forms]![frmDeal]![frmDealsSub].Form![Miles]) Then
  12.   blnError = True
  13. End If
try
Expand|Select|Wrap|Line Numbers
  1. 'It's either Not Null or Null
  2. If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Text62]) Then
  3.   blnError = True
  4.   trError = strError & "Vehicle Details" & vbCrLf
  5. Else
  6.   blnError = False
  7. End If
  8.  
  9. 'It's either Not Null or Null           
  10. If IsNull([Forms]![frmDeal]![frmDealsSub].Form![Miles]) Then
  11.   blnError = True
  12.   strError = strError & "Mileage" & vbCrLf
  13. Else
  14.   blnError = False
  15. End If
  16.  

Have tried your suggestion, but for some reason when a textbox is null "blnError" still shows "blnError = False" and not "blnError = True"! WHY?? Is it because at the very beginning of the code I have

Expand|Select|Wrap|Line Numbers
  1. Dim blnError As String
  2. blnError = False
  3.  
I have concluded the script with:

Expand|Select|Wrap|Line Numbers
  1.  If blnError = True Then
  2.                 Cancel = True
  3.                     MsgBox strError, vbOKOnly + vbCritical, "Stop!"
  4.                          Exit Sub
  5.            Else: GoTo Continue 
  6.  End If
  7.  
  8.  
Would this be right? As I get the feeling this code is not as you guys would write it! ("Continue:" is where the concluding code is to complete the task)

Your help please as I am struggling with getting blnError to equal the correct action ie False when False and True when True.
Nov 4 '07 #6
boliches
62 New Member
I meant to ask how you "Formatted and Tagged" the script to make it easier to read, also what is the benefit of putting the script in the "Before Update" event procedure as against on a Command Button? Is it a speed related thing?
Nov 4 '07 #7
ADezii
8,834 Recognized Expert Expert
I meant to ask how you "Formatted and Tagged" the script to make it easier to read, also what is the benefit of putting the script in the "Before Update" event procedure as against on a Command Button? Is it a speed related thing?
Have tried your suggestion, but for some reason when a textbox is null "blnError" still shows "blnError = False" and not "blnError = True"! WHY?? Is it because at the very beginning of the code I have
Expand|Select|Wrap|Line Numbers
  1. Dim blnError As String
  2. blnError = False
Expand|Select|Wrap|Line Numbers
  1. 'The correct Syntax should be:
  2. Dim blnError As Boolean
  3. blnError = False
I meant to ask how you "Formatted and Tagged" the script to make it easier to read, also what is the benefit of putting the script in the "Before Update" event procedure as against on a Command Button? Is it a speed related thing?
The BeforeUpdate() Event of the Form fires before the actual data present on the Form is Saved to the underlying Record Source and is the logical location for Validation Code. You 'Format' and 'Tag' code segments by the use of Indentations and the Code Tags present in Edit Mod (#). Select a specific code block, then click on the # sign and designate the code context as text, vb, sql, etc.

http://www.thescripts.com/forum/faq...._read_and_post

boliches, there appears to numerous problems with your code segment, too many for a back-and-forth conversation. If you like, you can send me the Database as an E-Mail Attachment and I'll have a good look at it when I get a chance. The only problem is that it will not be anytime soon and the code itself is not simply a couple of lines. Let me know what you would like to do.
Nov 4 '07 #8
boliches
62 New Member
Have amended the syntax, but still am failing to get the blnError = False to blnError = True when a text box is "Null". What am I doing wrong?

Thanks for the update on Formatting etc.

Regards
Nov 4 '07 #9
boliches
62 New Member
Have amended the syntax, but still am failing to get the blnError = False to blnError = True when a text box is "Null". What am I doing wrong?

Thanks for the update on Formatting etc.

Regards

Thanks for your interest in my problem, but the database is quite sizeable and may be difficult for me to get you to where the problem is within the project.

My main issue here is that I want to alert a user that info is missing from a form, and therfore (via a msgbox) inform that user which items are missing! Have I gone about it in totally the wrong way? If so could you please advise.

Many thanks. (Really appreciate your time!)
Nov 4 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

6
4839
by: Steven James Samuel Stapleton | last post by:
Will calling ksort() on an array speed up it's access? For example, I have the array $file_index, which is accessed by a key (the entry id) and has two sub elements in a one dimensional array (line number of the start of the entry in the file, and the byte offset of the start of the entry). so, I might have an array that can be represented thus: {
0
1405
by: pilar | last post by:
Hi All, It is possible to restrict data entry for 2 fields at the same time?, i know how this may sound for you, please don't insult me (just kidding, this is a great newsgroup). In my first Access database I just found a big design mistake. There is a table - tblsystem- with 2 fields -upperprinter and lowerprinter- this 2 fields contains the same type of data, they store the printers serial numbers. Now I found duplicate entries for the...
2
2022
by: David C. Barber | last post by:
upsized an MDB to ADP/SQL Server 2000 under Access 2000. All the DAO code that I've changed to ADO code is working fine, HOWEVER the form Record Source itself does not seem willing to return data. I've set the Record Source to both the query, and the SQL contained within the query, and although the system pauses long enough to have gone out and retrieved the data, I can't see it. The form itself remains gray. In addition: ...
0
2428
by: Gary Shell | last post by:
I am experiencing some strange behavior between a UserControl's validating event and a treeview control. Initially, I thought it was related to an issue in the Knowledgebase article 810852 (http://support.microsoft.com/kb/810852), but then I realized that the hotfix mentioned was in .Net v1.1, which I am using. I took the sample from that article and recreated the situation I see in my application. (Code included below.) If you run the...
8
2039
by: Martin | last post by:
I hope not, but, I think the answer to this question is "it can't be done". Northwind sample database. Orders form. Go to a new record. Select a customer in "Bill To:" Don't enter any products whatsoever. Now click or page up/down away from this new record. You just created a new order without a single item having been ordered. Not something a user should be able to do.
1
1832
by: jhutchings | last post by:
Hello all, I have a form I designed for data entry. However, when I set the form properties to Data Entry mode, the form completely disappears for Access 2000 users. All they see is a white blank space. What could be causing this? Thanks!
3
1967
by: Hamed | last post by:
Hello I have a Data Entry Form having some controls including a TextBox. When the user types an entry, I query a table and if it was entered before, I ask the user (using ShowModal method of a custom message form) if he wants to see his old entry in a new form. if he/she choose Yes, I create a new form and show the previously entered data in it. The problem is when I create and show the new form, the validating event is fired two...
2
3351
by: seltzer | last post by:
I am using Access 2000 but I also have the 2003 version. I am working on creating a data entry form in Access for a research study. Since there is a maximum of 255 fields per table in Access, I have to split the fields up (unfortunately). I am creating a form for each section and all of the respective fields, and then I am putting all these forms into one larger form as subforms. I have a few questions & am hoping someone has answers: ...
8
4119
by: Peted | last post by:
I have an amazing problem which i think i have no hope of solving Im working with a c# dot net module that is hosted by and runs under a delphi form envrioment. Dont ask me how this insanity has prevailed it just is :) My problem is this im trying to validate the contents of a textbox (it has to be a normal textbox) and on a c# winforms and i am calling the textbox validating
0
7874
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8368
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8000
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6652
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
3854
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3895
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2383
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1476
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1205
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.