Results 1 to 29 of 29

Thread: [RESOLVED] Problem on Validation of Textbox

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2013
    Posts
    74

    Resolved [RESOLVED] Problem on Validation of Textbox

    Kindly check below code. It is still saving if the textboxes are still empty. Please help

    Code:
    Private Sub Order()
    Call MySs
    dttrucktime = dtatatime.Value
    Dim cTemp As Control
        For Each cTemp In Controls
            If TypeOf cTemp Is TextBox Then
                If Len(Trim(cTemp.Text)) = 0 Then
                    MsgBox "Fill all the text boxes"
                    Exit For
                End If
            End If
        Next
    
    With ss
        .AddNew
        !OrderID = txtOR.Text
        !ClientName = cmbClient.Text
        !ClientID = txtCID.Text
        !CLientShipmentRef = txtCReference.Text
        !BLTruckNumber = txtBLNum.Text
        !DBShipmentRef = txtDBRef.Text
        !ETA_Date = dtdateeta.Value
        !ETA_Time = dtetatime.Value
        !ATA_Date = dtatadate.Value
        !ATA_Time = dtatatime.Value
        !ShipperName = txtShipper.Text
        !PONumber = txtPONum.Text
        !Amount = txtAmount.Text
        !Currency = cmbCurrency.Text
        !InvoiceNumber = txtInvoice.Text
        !Packages = Val(txtPackages.Text)
        !APackages = Val(txtapackage.Text)
        !UnitPackages = cmbUnit.Text
        !Packages2 = Val(txtPackages2.Text)
        !APackages2 = Val(txtapackage2.Text)
        !UnitPackages2 = cmbPackages2.Text
        !Weight = txtweight.Text
        !AWeight = txtaweight.Text
        !UnitWeight = cmbweight.Text
        !Volume = txtvolume.Text
        !AVolume = txtavolume.Text
        !UnitVolume = cmbvolume.Text
        !Trucks = Val(txtNumTrucks.Text)
        !ATrucks = Val(txtatrucks.Text)
        !SKU = Val(txtSKU.Text)
        !ASKU = Val(txtaSKU.Text)
        !UnitSKU = cmbSKU.Text
        !TDate = dttruckdate.Value
        !TTime = dttrucktime.Value
        !Offloading_Started = chkoffstarted.Value
        !OSDate = dtoffloadingstarted.Value
        !OSTime = dtoffstartedtime.Value
        !Offloading_Finished = chkofffinished.Value
        !OFDate = dtoffloadingfinished.Value
        !OFTime = dtoffloadingfintime.Value
        !PutAway_Started = chkputstarted.Value
        !PSDate = dtputawaystarted.Value
        !PSTime = dtputstartedtime.Value
        !PutAway_Finished = chkputfinished.Value
        !PFDate = dtputawayfinished.Value
        !PFTime = dtputfinishedtime.Value
        !Shipment_Completed = chkshipmentcompleted.Value
        !SCDate = dtshipmentdate.Value
        !SCTime = dtshicomptime.Value
        !Status = txtStatus.Text
        !user = lbluser.Caption
        !Create_Date = lblDate.Caption
        !Create_Time = lblTime.Caption
        .Update
    End With
      
    
    End Sub

  2. #2
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    Re: Problem on Validation of Textbox

    Not sure what you mean...however, your Exit For statement only exits the For-Loop, the rest of the code after that will continue. You can replace it with an Exit Sub, or use other means.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Sep 2013
    Posts
    74

    Re: Problem on Validation of Textbox

    Once i click the save button, i need a command that will make sure that all textbooks should not be empty. It should not save, if there is at least one text box empty.

  4. #4
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    Re: Problem on Validation of Textbox

    Okay, you CAN use Exit Sub (not a good practice, but okay in this instance)
    Or you could rewrite it like this:

    Code:
    Private Sub Order()
    Dim tboxEmpty as Boolean
    tboxEmpty = False
    Call MySs
    dttrucktime = dtatatime.Value
    Dim cTemp As Control
        For Each cTemp In Controls
            If TypeOf cTemp Is TextBox Then
                If Len(Trim(cTemp.Text)) = 0 Then
                    MsgBox "Fill all the text boxes"
                    tboxEmpty = True
                End If
            End If
        Next
    
    if tboxEmpty = False then
    With ss
        .AddNew
        !OrderID = txtOR.Text
        !ClientName = cmbClient.Text
        !ClientID = txtCID.Text
        !CLientShipmentRef = txtCReference.Text
        !BLTruckNumber = txtBLNum.Text
        !DBShipmentRef = txtDBRef.Text
        !ETA_Date = dtdateeta.Value
        !ETA_Time = dtetatime.Value
        !ATA_Date = dtatadate.Value
        !ATA_Time = dtatatime.Value
        !ShipperName = txtShipper.Text
        !PONumber = txtPONum.Text
        !Amount = txtAmount.Text
        !Currency = cmbCurrency.Text
        !InvoiceNumber = txtInvoice.Text
        !Packages = Val(txtPackages.Text)
        !APackages = Val(txtapackage.Text)
        !UnitPackages = cmbUnit.Text
        !Packages2 = Val(txtPackages2.Text)
        !APackages2 = Val(txtapackage2.Text)
        !UnitPackages2 = cmbPackages2.Text
        !Weight = txtweight.Text
        !AWeight = txtaweight.Text
        !UnitWeight = cmbweight.Text
        !Volume = txtvolume.Text
        !AVolume = txtavolume.Text
        !UnitVolume = cmbvolume.Text
        !Trucks = Val(txtNumTrucks.Text)
        !ATrucks = Val(txtatrucks.Text)
        !SKU = Val(txtSKU.Text)
        !ASKU = Val(txtaSKU.Text)
        !UnitSKU = cmbSKU.Text
        !TDate = dttruckdate.Value
        !TTime = dttrucktime.Value
        !Offloading_Started = chkoffstarted.Value
        !OSDate = dtoffloadingstarted.Value
        !OSTime = dtoffstartedtime.Value
        !Offloading_Finished = chkofffinished.Value
        !OFDate = dtoffloadingfinished.Value
        !OFTime = dtoffloadingfintime.Value
        !PutAway_Started = chkputstarted.Value
        !PSDate = dtputawaystarted.Value
        !PSTime = dtputstartedtime.Value
        !PutAway_Finished = chkputfinished.Value
        !PFDate = dtputawayfinished.Value
        !PFTime = dtputfinishedtime.Value
        !Shipment_Completed = chkshipmentcompleted.Value
        !SCDate = dtshipmentdate.Value
        !SCTime = dtshicomptime.Value
        !Status = txtStatus.Text
        !user = lbluser.Caption
        !Create_Date = lblDate.Caption
        !Create_Time = lblTime.Caption
        .Update
    End With
    End If
    
    End Sub

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Sep 2013
    Posts
    74

    Re: Problem on Validation of Textbox

    Thank you Sam, how do i put restriction on this. there are 2 text boxes that does not require validation as the input is automatic, eg. Order ID and the Client ID which if you select the name from the combo box will show the Client ID on the other textbox?

  6. #6
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    Re: Problem on Validation of Textbox

    well, if those 2 boxes are automatically filled in, you don't have to worry....your loop will simply pass by those two without signalling they need to have an entry (as they already do).

  7. #7
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Problem on Validation of Textbox

    You would need to add additional if tests or a select case to exclude those textboxes

    Code:
            If Not (ctemp.Name="OrderID" or cTemp.Name="ClientID") Then
                If Len(Trim(cTemp.Text)) = 0 Then
                    MsgBox "Fill all the text boxes"
                    tboxEmpty = True
                End If
           End If

  8. #8
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    Re: Problem on Validation of Textbox

    Quote Originally Posted by DataMiser View Post
    You would need to add additional if tests or a select case to exclude those textboxes

    Code:
            If Not (ctemp.Name="OrderID" or cTemp.Name="ClientID") Then
                If Len(Trim(cTemp.Text)) = 0 Then
                    MsgBox "Fill all the text boxes"
                    tboxEmpty = True
                End If
           End If
    True. But why? If they are already populated, why write extra code? (Just sayin')

  9. #9
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Problem on Validation of Textbox

    duh... I missed that part, I just saw something about not needing to validate those and jumped to the conclusion that they should be excluded when of course there is no need to do so.
    I guess I stopped reading before I reached the end.

  10. #10
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141

    Re: Problem on Validation of Textbox

    Quote Originally Posted by SamOscarBrown View Post
    True. But why? If they are already populated, why write extra code? (Just sayin')
    Think outside the box. What if the user deleted one of these values from the textbox? One thing I have learned over the years is users don't always use your application the way you intended them to.

    If you are prepopulating the Order ID and the Client ID textboxes and the users should not be able to change these values then I would use a label or set the textboxes enabled property to false.

  11. #11
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    Re: Problem on Validation of Textbox

    Correct....that is why I would leave it to check ALL textboxes to see if empty or not, and NOT exclude them from the test. I am the interface as Project Manager directly with the customer....every workday....in their location...so I have also learned (over the MANY years) that someone will hit a 'wrong' button, delete something, put in text when needing numbers, put in invalid entries, etc etc etc. That's why we have so many IPRs. Am fortunate to have direct access to testors (on the customer side) almost any time desired. Use of 'locked' controls. labels are good options to preclude data entry changes.

  12. #12
    Frenzied Member HanneSThEGreaT's Avatar
    Join Date
    Nov 2003
    Location
    Vereeniging, South Africa
    Posts
    1,492

    Re: Problem on Validation of Textbox

    It is also good to provide the user details as to why the records haven't been saved yet. At this stage, the user will press the save button and proceed with the next entry. He / she will not know if the details have been saved or not. Include an ELse clause to inform the user that the record has not been saved or, disable / enable the Save button based on the tboxEmpty variable
    VB.NET MVP 2008 - Present

  13. #13
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Problem on Validation of Textbox

    Quote Originally Posted by SamOscarBrown View Post
    Okay, you CAN use Exit Sub (not a good practice, but okay in this instance)
    What other instance are you referring to?
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  14. #14
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: Problem on Validation of Textbox

    I think it's good to let the user know exactly where the 'problems' are. In this case, if a TextBox fails the validation I'd highlight it and then go onto the next one. A simple mod to Sam's code
    Code:
    Private Sub Order()
    Dim tboxEmpty As Boolean
    Call MySs
    dttrucktime = dtatatime.Value
    Dim cTemp As Control
    For Each cTemp In Controls
        If TypeOf cTemp Is TextBox Then
            If Len(Trim(cTemp.Text)) = 0 Then
                cTemp.BackColor = vbRed
                tboxEmpty = True
            Else
                cTemp.BackColor = vbWhite
            End If
        End If
    Next
    If Not tboxEmpty Then
        With ss
            .AddNew
            !OrderID = txtOR.Text
            !ClientName = cmbClient.Text
            !ClientID = txtCID.Text
            !CLientShipmentRef = txtCReference.Text
            !BLTruckNumber = txtBLNum.Text
            !DBShipmentRef = txtDBRef.Text
            !ETA_Date = dtdateeta.Value
            !ETA_Time = dtetatime.Value
            !ATA_Date = dtatadate.Value
            !ATA_Time = dtatatime.Value
            !ShipperName = txtShipper.Text
            !PONumber = txtPONum.Text
            !Amount = txtAmount.Text
            !Currency = cmbCurrency.Text
            !InvoiceNumber = txtInvoice.Text
            !Packages = Val(txtPackages.Text)
            !APackages = Val(txtapackage.Text)
            !UnitPackages = cmbUnit.Text
            !Packages2 = Val(txtPackages2.Text)
            !APackages2 = Val(txtapackage2.Text)
            !UnitPackages2 = cmbPackages2.Text
            !Weight = txtweight.Text
            !AWeight = txtaweight.Text
            !UnitWeight = cmbweight.Text
            !Volume = txtvolume.Text
            !AVolume = txtavolume.Text
            !UnitVolume = cmbvolume.Text
            !Trucks = Val(txtNumTrucks.Text)
            !ATrucks = Val(txtatrucks.Text)
            !SKU = Val(txtSKU.Text)
            !ASKU = Val(txtaSKU.Text)
            !UnitSKU = cmbSKU.Text
            !TDate = dttruckdate.Value
            !TTime = dttrucktime.Value
            !Offloading_Started = chkoffstarted.Value
            !OSDate = dtoffloadingstarted.Value
            !OSTime = dtoffstartedtime.Value
            !Offloading_Finished = chkofffinished.Value
            !OFDate = dtoffloadingfinished.Value
            !OFTime = dtoffloadingfintime.Value
            !PutAway_Started = chkputstarted.Value
            !PSDate = dtputawaystarted.Value
            !PSTime = dtputstartedtime.Value
            !PutAway_Finished = chkputfinished.Value
            !PFDate = dtputawayfinished.Value
            !PFTime = dtputfinishedtime.Value
            !Shipment_Completed = chkshipmentcompleted.Value
            !SCDate = dtshipmentdate.Value
            !SCTime = dtshicomptime.Value
            !Status = txtStatus.Text
            !user = lbluser.Caption
            !Create_Date = lblDate.Caption
            !Create_Time = lblTime.Caption
            .Update
            MsgBox "Update Complete"
        End With
    Else
        MsgBox "Please enter data into the highlighted items"
    End If
    End Sub

  15. #15
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    Re: Problem on Validation of Textbox

    Quote Originally Posted by Nightwalker83 View Post
    What other instance are you referring to?
    "This" instance...one time use. That is all I am saying...just not a good practice. :-)

  16. #16

    Thread Starter
    Lively Member
    Join Date
    Sep 2013
    Posts
    74

    Re: Problem on Validation of Textbox

    I have tried Google's code and it work . But how to put a message or alert that the order was not saved.

  17. #17
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: Problem on Validation of Textbox

    Just change
    Code:
    Else
        MsgBox "Please enter data into the highlighted items"
    End If
    to
    Code:
    Else
        MsgBox "Changes have Not been saved. Please enter data into the highlighted items and re-try"
    End If

  18. #18
    Frenzied Member
    Join Date
    Jan 2009
    Location
    Watch Window(Shift+f9)
    Posts
    1,879

    Re: Problem on Validation of Textbox

    Try the following way .Hope it might help .
    Code:
    Private Sub Order()
    Dim tboxEmpty As Boolean
    Call MySs
    dttrucktime = dtatatime.Value
    Dim cTemp As Control
    For Each cTemp In Controls
        If TypeOf cTemp Is TextBox Then
            If Len(Trim(cTemp.Text)) = 0 Then
                Call MsgBox(ctemp.Name & " Cannot be blank")
                cTemp.setfocus
                exit sub
       End If
      End If
    Next
    'If Not tboxEmpty Then 'it is not necessary
        With ss
            .AddNew
            !OrderID = txtOR.Text
            !ClientName = cmbClient.Text
            !ClientID = txtCID.Text
            !CLientShipmentRef = txtCReference.Text
            !BLTruckNumber = txtBLNum.Text
            !DBShipmentRef = txtDBRef.Text
            !ETA_Date = dtdateeta.Value
            !ETA_Time = dtetatime.Value
            !ATA_Date = dtatadate.Value
            !ATA_Time = dtatatime.Value
            !ShipperName = txtShipper.Text
            !PONumber = txtPONum.Text
            !Amount = txtAmount.Text
            !Currency = cmbCurrency.Text
            !InvoiceNumber = txtInvoice.Text
            !Packages = Val(txtPackages.Text)
            !APackages = Val(txtapackage.Text)
            !UnitPackages = cmbUnit.Text
            !Packages2 = Val(txtPackages2.Text)
            !APackages2 = Val(txtapackage2.Text)
            !UnitPackages2 = cmbPackages2.Text
            !Weight = txtweight.Text
            !AWeight = txtaweight.Text
            !UnitWeight = cmbweight.Text
            !Volume = txtvolume.Text
            !AVolume = txtavolume.Text
            !UnitVolume = cmbvolume.Text
            !Trucks = Val(txtNumTrucks.Text)
            !ATrucks = Val(txtatrucks.Text)
            !SKU = Val(txtSKU.Text)
            !ASKU = Val(txtaSKU.Text)
            !UnitSKU = cmbSKU.Text
            !TDate = dttruckdate.Value
            !TTime = dttrucktime.Value
            !Offloading_Started = chkoffstarted.Value
            !OSDate = dtoffloadingstarted.Value
            !OSTime = dtoffstartedtime.Value
            !Offloading_Finished = chkofffinished.Value
            !OFDate = dtoffloadingfinished.Value
            !OFTime = dtoffloadingfintime.Value
            !PutAway_Started = chkputstarted.Value
            !PSDate = dtputawaystarted.Value
            !PSTime = dtputstartedtime.Value
            !PutAway_Finished = chkputfinished.Value
            !PFDate = dtputawayfinished.Value
            !PFTime = dtputfinishedtime.Value
            !Shipment_Completed = chkshipmentcompleted.Value
            !SCDate = dtshipmentdate.Value
            !SCTime = dtshicomptime.Value
            !Status = txtStatus.Text
            !user = lbluser.Caption
            !Create_Date = lblDate.Caption
            !Create_Time = lblTime.Caption
            .Update
            MsgBox "Update Complete"
        End With
    End If
    End Sub

  19. #19

    Thread Starter
    Lively Member
    Join Date
    Sep 2013
    Posts
    74

    Re: Problem on Validation of Textbox

    Thank you Doogle and thank you to all the contributors.

  20. #20

    Thread Starter
    Lively Member
    Join Date
    Sep 2013
    Posts
    74

    Re: [RESOLVED] Problem on Validation of Textbox

    Hi Doogle , i just have a new problem for the same topic. If i have 5 empty text boxes i am getting 5 message box also. How do i lessen the message box into 1 for all the empty boxes?>

  21. #21
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141

    Re: [RESOLVED] Problem on Validation of Textbox

    What does the code look like that you are currently using?

  22. #22
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: [RESOLVED] Problem on Validation of Textbox

    If you're using the code in Post#14 you should only see 1 message.

  23. #23

    Thread Starter
    Lively Member
    Join Date
    Sep 2013
    Posts
    74

    Re: [RESOLVED] Problem on Validation of Textbox

    I have used the code in#14 but, if i have 2 empty text boxes i am receiving 2 messages

  24. #24
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: [RESOLVED] Problem on Validation of Textbox

    Quote Originally Posted by Amabel View Post
    I have used the code in#14 but, if i have 2 empty text boxes i am receiving 2 messages
    Are you sure you're using the exact code in Post #14? I can't see any way you can receive more than one message.

    Perhaps you'd like to post your code as it is now

  25. #25

    Thread Starter
    Lively Member
    Join Date
    Sep 2013
    Posts
    74

    Re: [RESOLVED] Problem on Validation of Textbox

    Code:
    Private Sub Order()
    Dim tboxEmpty As Boolean
    Call MySs
    dttrucktime = dtatatime.Value
    Dim cTemp As Control
    For Each cTemp In Controls
        If TypeOf cTemp Is TextBox Then
            If Len(Trim(cTemp.Text)) = 0 Then
               
                cTemp.BackColor = vbRed
                tboxEmpty = True
                cmdedit.Enabled = True
                   MsgBox "Changes have Not been saved. Please enter data into the highlighted items and re-try"
                   cmdedit.Enabled = True
            Else
                cTemp.BackColor = vbWhite
                   CmdAdd.Enabled = True
                
            End If
        End If
    Next
    If Not tboxEmpty Then
    With ss
        .AddNew
        !OrderID = txtOR.Text
        !ClientName = cmbClient.Text
        !ClientID = txtCID.Text
        !CLientShipmentRef = txtCReference.Text
        !BLTruckNumber = txtBLNum.Text
        !DBShipmentRef = txtDBRef.Text
        !ETA_Date = dtdateeta.Value
        !ETA_Time = dtetatime.Value
        !ATA_Date = dtatadate.Value
        !ATA_Time = dtatatime.Value
        !ShipperName = txtShipper.Text
        !PONumber = txtPONum.Text
        !Amount = txtAmount.Text
        !Currency = cmbCurrency.Text
        !InvoiceNumber = txtInvoice.Text
        !Packages = Val(txtPackages.Text)
        !APackages = Val(txtapackage.Text)
        !UnitPackages = cmbUnit.Text
        !Packages2 = Val(txtPackages2.Text)
        !APackages2 = Val(txtapackage2.Text)
        !UnitPackages2 = cmbPackages2.Text
        !Weight = txtweight.Text
        !AWeight = txtaweight.Text
        !UnitWeight = cmbweight.Text
        !Volume = txtvolume.Text
        !AVolume = txtavolume.Text
        !UnitVolume = cmbvolume.Text
        !Trucks = Val(txtNumTrucks.Text)
        !ATrucks = Val(txtatrucks.Text)
        !SKU = Val(txtSKU.Text)
        !ASKU = Val(txtaSKU.Text)
        !UnitSKU = cmbSKU.Text
        !TDate = dttruckdate.Value
        !TTime = dttrucktime.Value
        !Offloading_Started = chkoffstarted.Value
        !OSDate = dtoffloadingstarted.Value
        !OSTime = dtoffstartedtime.Value
        !Offloading_Finished = chkofffinished.Value
        !OFDate = dtoffloadingfinished.Value
        !OFTime = dtoffloadingfintime.Value
        !PutAway_Started = chkputstarted.Value
        !PSDate = dtputawaystarted.Value
        !PSTime = dtputstartedtime.Value
        !PutAway_Finished = chkputfinished.Value
        !PFDate = dtputawayfinished.Value
        !PFTime = dtputfinishedtime.Value
        !Shipment_Completed = chkshipmentcompleted.Value
        !SCDate = dtshipmentdate.Value
        !SCTime = dtshicomptime.Value
        !Status = txtStatus.Text
        !user = lbluser.Caption
        !Create_Date = lblDate.Caption
        !Create_Time = lblTime.Caption
    
        .Update
        MsgBox "Successfully saving Data", vbInformation, "Order Management"
        cmdedit.Enabled = False
        CmdAdd.Enabled = False
        cmdnew.Enabled = True
    End With
    End If
    
    
    End Sub

  26. #26
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: [RESOLVED] Problem on Validation of Textbox

    This line
    Code:
    MsgBox "Changes have Not been saved. Please enter data into the highlighted items and re-try"
    is in the wrong place, see Post #17

  27. #27

    Thread Starter
    Lively Member
    Join Date
    Sep 2013
    Posts
    74

    Re: [RESOLVED] Problem on Validation of Textbox

    where do i have to put this?

  28. #28
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: [RESOLVED] Problem on Validation of Textbox

    Code:
    Private Sub Order()
    Dim tboxEmpty As Boolean
    Call MySs
    dttrucktime = dtatatime.Value
    Dim cTemp As Control
    For Each cTemp In Controls
        If TypeOf cTemp Is TextBox Then
            If Len(Trim(cTemp.Text)) = 0 Then
                cTemp.BackColor = vbRed
                tboxEmpty = True
            Else
                cTemp.BackColor = vbWhite
            End If
        End If
    Next
    If Not tboxEmpty Then
        With ss
            .AddNew
            !OrderID = txtOR.Text
            !ClientName = cmbClient.Text
            !ClientID = txtCID.Text
            !CLientShipmentRef = txtCReference.Text
            !BLTruckNumber = txtBLNum.Text
            !DBShipmentRef = txtDBRef.Text
            !ETA_Date = dtdateeta.Value
            !ETA_Time = dtetatime.Value
            !ATA_Date = dtatadate.Value
            !ATA_Time = dtatatime.Value
            !ShipperName = txtShipper.Text
            !PONumber = txtPONum.Text
            !Amount = txtAmount.Text
            !Currency = cmbCurrency.Text
            !InvoiceNumber = txtInvoice.Text
            !Packages = Val(txtPackages.Text)
            !APackages = Val(txtapackage.Text)
            !UnitPackages = cmbUnit.Text
            !Packages2 = Val(txtPackages2.Text)
            !APackages2 = Val(txtapackage2.Text)
            !UnitPackages2 = cmbPackages2.Text
            !Weight = txtweight.Text
            !AWeight = txtaweight.Text
            !UnitWeight = cmbweight.Text
            !Volume = txtvolume.Text
            !AVolume = txtavolume.Text
            !UnitVolume = cmbvolume.Text
            !Trucks = Val(txtNumTrucks.Text)
            !ATrucks = Val(txtatrucks.Text)
            !SKU = Val(txtSKU.Text)
            !ASKU = Val(txtaSKU.Text)
            !UnitSKU = cmbSKU.Text
            !TDate = dttruckdate.Value
            !TTime = dttrucktime.Value
            !Offloading_Started = chkoffstarted.Value
            !OSDate = dtoffloadingstarted.Value
            !OSTime = dtoffstartedtime.Value
            !Offloading_Finished = chkofffinished.Value
            !OFDate = dtoffloadingfinished.Value
            !OFTime = dtoffloadingfintime.Value
            !PutAway_Started = chkputstarted.Value
            !PSDate = dtputawaystarted.Value
            !PSTime = dtputstartedtime.Value
            !PutAway_Finished = chkputfinished.Value
            !PFDate = dtputawayfinished.Value
            !PFTime = dtputfinishedtime.Value
            !Shipment_Completed = chkshipmentcompleted.Value
            !SCDate = dtshipmentdate.Value
            !SCTime = dtshicomptime.Value
            !Status = txtStatus.Text
            !user = lbluser.Caption
            !Create_Date = lblDate.Caption
            !Create_Time = lblTime.Caption
            .Update
            MsgBox "Update Complete"
        End With
    Else
        MsgBox "Changes have Not been saved. Please enter data into the highlighted items and re-try"
    End If
    End Sub

  29. #29

    Thread Starter
    Lively Member
    Join Date
    Sep 2013
    Posts
    74

    Re: [RESOLVED] Problem on Validation of Textbox

    Thanks a lot Doogle

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width