Clear Text Box Tied to Combo Box?



I have a Text Box (EmployeeID) that automatically updates when a Combo Box
selection (EmployeeName) is selected. However, there are two issues with my
text box.

1. When I open the form, the text box is already populated with an
EmployeeID (the last one entered, I think), even though there is nothing in
the Combo Box yet. How can I get the form to open with that text box BLANK?

2. I have a code that clears the form once a submission is made. It clears
EVERY field... except for this text box. It even clears the combo box! How do
I get this text box to clear too?

Here is my code:

For Each ctl In Me.Controls
Select Case ctl.ControlType
Case acCheckBox, acComboBox, acTextBox
If ctl.ControlSource = "" Then
ctl.Value = Null
End If
Case Else
End Select
Next ctl

Works like a charm for everything but this EmployeeID text box...





I am not entirely sure what that means.... I am guessing that it has
something to do with "EmployeeID" from my query qryAttendance being in the
Control Source. If that is the case, then yes, it is bound.

However... if I take that out of the Control Source (and make it UNBOUNND),
I lose the functionality that updates the EmployeeID text box when the combo
box is updated.

Here is my code to update the text box when the combo box is updated:

Private Sub cboEmployeeName_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[EmployeeID] = " & Str(Nz(Me![cboEmployeeName], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

(This was "stolen" from someone else, so I don't know too much about it!!)


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question