CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2001
    Posts
    29

    2 Questions, Validate MaskEditBox & Edit DB record

    Hi,

    Q1 From what I have read my code for edit in Q1 below should work, I’m missing something, the data is not being update My DB has a key field called ID.

    Q2. How do I validate a MaskEditBox My code is below in Q2.

    Any help appreciated.

    Regards,

    Alan.

    Q1
    Private Sub cmdUpdate_Click()
    'Edit and save customer details
    With Customers
    .Edit
    'Trap for null text boxes
    If MaskABN.Text = "" Then
    Customers.Fields("ABN").Value = Null
    Else
    Customers.Fields("ABN").Value = MaskABN.Text
    End If

    Customers("ABN") = MaskABN.Text
    Customers("Telephone") = MaskTelephone.Text
    .Update
    End With
    End Sub

    End of Code

    Q2.
    ‘I have a masked edit box that needs validating if a number is missed out.

    Private Sub MaskABN_GotFocus()
    MaskABN.Mask = "## ### ### ###"
    End Sub

    Private Sub MaskABN_LostFocus()
    If MaskABN.Mask <> THE FORMAT OF THE MASK AND COMPLETE then
    Msg “Do Something”
    End Sub



  2. #2
    Join Date
    Aug 2000
    Location
    NY, USA
    Posts
    632

    Re: 2 Questions, Validate MaskEditBox & Edit DB record

    Do validation in Validate event, trap blank this way:

    private Sub MaskEdBox1_Validate(Cancel as Boolean)
    If MaskEdBox1.ClipText = "" then
    MsgBox "Box cannot be blank"
    Cancel = true
    End If
    End Sub



    Unfortunately, your other problems are unclear for me. Try to formulate them the different way.

    Vlad


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

Featured