PDA

Click to See Complete Forum and Search --> : Debugging a statement


Gimpster
Jan 14th, 2000, 02:04 AM
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.

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).]

Aaron Young
Jan 14th, 2000, 02:08 AM
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
aarony@redwingsoftware.com
ajyoung@pressenter.com

Gimpster
Jan 14th, 2000, 02:52 AM
Yes, that was part of the problem, also I needed to change the 'or's to 'and's. Now it works. Thanks

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