Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 automaticallyselecting only value in listbox field

Author  Topic 

xkel936
Starting Member

4 Posts

Posted - 2007-03-15 : 15:47:28
Hello,

I am new to SQL and I am populating a listbox with a sql statement that returns two values. These values will change from user to user, but will never change for that one user. I have populated the two fields in the Form_open command, but in order for them to become a value they need to be clicked on by the user. I want to bypass that part. Can anyone point me in the right direction? I have included what I have done.

Thanks!



Private Sub Form_Open(Cancel As Integer)

Dim clockID As String
Dim EmployeeId As Integer
Dim db As Database
Dim rs As Recordset
Dim sql As String

Set db = CurrentDb

clockID = GetOpSysUser
sql = "SELECT EMP_ID FROM EMPLOYEES WHERE CLOCK_ID = '" & clockID & " '"
Set rs = db.OpenRecordset(sql)
EmployeeId = rs.Fields(0)
Name_Combo.RowSource = "SELECT EMP_ID, EMP_NAME FROM EMPLOYEES WHERE CLOCK_ID = '" & clockID & "'"
company_text.RowSource = "SELECT COMPANY_NAME FROM COMPANY, EMPLOYEES WHERE COMPANY.COMPANY_ID = EMPLOYEES.COMPANY_ID AND CLOCK_ID = '" & clockID & "'"


'Me.Hours_text.Value = " "
rs.Close

End Sub
   

- Advertisement -