943,929 Members | Top Members by Rank

Ad:
Apr 30th, 2009
0

Text Box populated by Combo Box

Expand Post »
Hello,

I have an access database with 3 tables. The table i am working on is tblemployee.

On a form i have a combo box with the employee numbers. Now, when a user chooses an employee number from the drop down box, i want the initial and name of that employee to appear in a non-editable text box.

I have been trying to get this to work but get errors.

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Private Sub Employee_Change()
  2. If Employee.Text > 0 Then
  3. txtname.Visible = True
  4. Dim Sqltxt As String
  5. Sqltxt = "SELECT surname FROM TBLEmployee where [employee number] = " & Employee
  6.  
  7. DoCmd.OpenQuery (Sqltxt)
  8.  
  9. Else
  10. txtname.Visible = False
  11. End If
  12. End Sub

I have put the above in the On Change Event in combo box "Employee".

Any help would be greatley apreaciated.

Thank you
Similar Threads
Reputation Points: 10
Solved Threads: 1
Posting Whiz
sam1 is offline Offline
300 posts
since Nov 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Find Data in an Access Field from Excel Macro
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Win98 v. Access 2002





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC