Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo box not working as desired 1

Status
Not open for further replies.

thefourthwall

IS-IT--Management
Feb 26, 2002
387
US
Hello,

I have a form from an existing query. The form displays cell phone #, ESN, Employee ID number, etc.

I created a combo box called cboCellNumSearch, using the built-in wizard and want the combo box to update the various controls based on the cell number I choose from the list.

Here's the query:
Code:
SELECT tblDevice.Cell_Number, tblDevice.Spare, tblDevice.Aircard, tblDevice.EID, tblDevice.Carrier, tblDevice.Model, tblDevice.Date_Last_Change, tblDevice.Direct_Connect_Number, tblDevice.Comments, tblDevice.ESN, tblEmployee.LAST_NAME, tblEmployee.FIRST_NAME, tblEmployee.MIDDLE_INITIAL, tblEmployee.NAME_SUFFIX, tblEmployee.EMPLOYEE_ID, tblEmployee.SHIELD, tblEmployee.TZS_CODE, tblEmployee.TITLE_CODE, tblEmployee.DATE_OF_ENTRY, tblEmployee.DATE_OF_RANK, tblEmployee.AD_USER_NAME, tblEmployee.SEX_CODE, tblEmployee.TZS_DESCRIPTION, tblEmployee.TITLE_DESCRIPTION, tblDevice.DoNotDisplayInAD
FROM tblDevice LEFT JOIN tblEmployee ON tblDevice.EID = tblEmployee.EMPLOYEE_ID
ORDER BY tblDevice.Cell_Number;
and the code behind the combo box (in the After Update event is
Code:
Private Sub cboCellNumSearch_AfterUpdate()
    ' Find the record that matches the control.
    Dim rs As Object

    Set rs = Me.Recordset.Clone
    rs.FindFirst "[EID] = " & Str(Nz(Me![cboCellNumSearch], 0))
    If Not rs.EOF Then Me.Bookmark = rs.Bookmark
    
End Sub
The controls do not update when I select a cell number from the list; what am I doing wrong?
 
Try this:

rs.FindFirst "[EID] = '" & Str(Nz(Me![cboCellNumSearch], 0)) & "'"

I hope this helps!
 

Then the problem was that the cell phone number field is defined as Text in your table. Syntax varies depending on the Datatype of the field. Your original code was correct if the cell number was defined as a Number.

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top