|
-
Jan 14th, 2000, 03:04 AM
#1
Thread Starter
Hyperactive Member
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).]
-
Jan 14th, 2000, 03:08 AM
#2
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]
-
Jan 14th, 2000, 03:52 AM
#3
Thread Starter
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|