Text Box populated by Combo Box

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Nov 2004
Posts: 259
Reputation: sam1 is an unknown quantity at this point 
Solved Threads: 1
sam1's Avatar
sam1 sam1 is offline Offline
Posting Whiz in Training

Text Box populated by Combo Box

 
0
  #1
Apr 30th, 2009
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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



Tag cloud for Visual Basic 4 / 5 / 6
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC