|
-
Feb 1st, 2000, 11:56 PM
#1
Thread Starter
Lively Member
I have a GoFind Command button that fills in all of the text, combos, etc, when clicked. There are tons of objects to be filled and I am trying to fill the ones that do not have a value entered with a different color and "Input". Is there a quicker way than the following code to fill all of these in or do I really have to go thru each object and fill it in?? Early Thanks.
If IsNull(tb!TransAssnmtDate) = True Then
txtDateAssnd.Text = "Input Date"
txtDateAssnd.ForeColor = vbRed
Else
txtDateAssnd.ForeColor = vbBlack
txtDateAssnd.Text = (tb!TransAssnmtDate)
End If
If IsNull(tb!transCompleted) = True Then
txtTransCmpleted.Text = "Input Date"
txtTransCmpleted.ForeColor = vbRed
Else
txtTransCmpleted.ForeColor = vbBlack
txtTransCmpleted.Text = (tb!transCompleted)
End If
IP: Logged
Frederik Gekiere
Junior Member posted 02-02-2000 10:54 AM
--------------------------------------------------------------------------------
You might try something like this:
Dim obj As Control
For Each obj In FormName.Controls
If TypeOf obj Is TextBox Then
If IsNull(obj.text) Then
'...
Else
'...
End If
End if
Next
you can also re-use the code by changing the type of the control (eg change TextBox into CheckBox and the code works for all checkboxex)
[This message has been edited by Frederik Gekiere (edited 02-02-2000).]
IP: Logged
VBAmateur
Junior Member posted 02-02-2000 11:19 AM
--------------------------------------------------------------------------------
Hey Frederik or someone else who is looking, Thanks but I also am joing these textboxes to fields in a DB and if the object is not null then it will be filled with whatever field it matches with in the DB. Is it still possible to fill in all of them in a quicker way. I shold have mentioned the DB part at first. Thanks.
-
Feb 2nd, 2000, 12:26 PM
#2
Try something like:
Create a Textbox Control Array for all fields you get from your DB, and call if txtDB..
Code:
Dim iIndex As Integer
For iIndex = 0 To txtDB.Count - 1
txtDB(iIndex).ForeColor = IIF(tb(iIndex), vbRed, vbBlack)
Next
Alternatively, Name all the Textboxes with the same name as it's Field preceeded with txt and add DB to the Tag Property of Each..
Code:
Dim oObj As Object
For Each oObj In Me
If TypeOf oObj Is Textbox Then
If oObj.Tag = "DB" Then
oObj.ForeColor = IIF(tb(Mid$(oObj.Name, 4)), vbRed, vbBlack)
End If
End If
Next
------------------
Aaron Young
Analyst Programmer
[email protected]
[email protected]
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
|