Results 1 to 3 of 3

Thread: Debugging a statement

  1. #1

    Thread Starter
    Hyperactive Member Gimpster's Avatar
    Join Date
    Oct 1999
    Location
    Redmond, WA 98052
    Posts
    331

    Post

    I have an If/Then statement that I'm having trouble with, I don't think I have it set up right. Here's what I'm trying to do, the statement updates a database, but that's not the problem, the problem is that I have three text boxes that could be empty and I need to keep the update statement from executing when the program comes across those text boxes, but only if the text box is empty. This is what I tried already and it didn't keep the program from executing the update statement from executing on the empty text boxes. Tell me what I need to change.

    Code:
    Public Function UpdateFields()
        Dim x As Object
        For Each x In Me.Controls()
            If Left(x.Name, 3) = "txt" Then
                If x.Name <> "txtdate_hired" Or x.Name <> "txtdate_terminated" Or x.Name <> "txtbirth_date" And x.Text = "" Then
                    Connection.Execute ("UPDATE Employees SET " & Mid(x.Name, 4) & "= '" & x.Text & "' WHERE ss_number = " & txtss_number.Text)
                End If
            End If
        Next x
        RecordChanged = False
    End Function

    ------------------
    Ryan


    [This message has been edited by Gimpster (edited 01-14-2000).]

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    At the End of your Expression you have x.Text = "" indicating it should execute if the Textbox (x) is Empty, change this to x.Text <> ""

    ------------------
    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]


  3. #3

    Thread Starter
    Hyperactive Member Gimpster's Avatar
    Join Date
    Oct 1999
    Location
    Redmond, WA 98052
    Posts
    331

    Post

    Yes, that was part of the problem, also I needed to change the 'or's to 'and's. Now it works. Thanks

    ------------------
    Ryan

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