Select bound Combobox value using VBA based on variable?

Silver_surfer

New member
Local time
Tomorrow, 02:44
Joined
Jan 29, 2020
Messages
14
So I have a bound combobox, lets call this Assigned_to
It has 2 Column, EmployeeID and Nama, with first column as bound column, and hidden
What I want is, to autofill this combobox with Nama, which defined in strUser and then lock it when user open the form
I have tried to use .RowSource property to no avail
Code:
Me.Assigned_To.RowSource = "SELECT Nama FROM Employees WHERE EmployeeID= Dlookup("EmployeeID","Employee",[Nama]= & strUser)"
Me.Assigned_To.Locked = True

strUser is a Global Variable declared in Gvar Module
Code:
Option Compare Database

    Global strUser As String
    Global strRole As String

Which in turn get the value when a user is login to the database
Code:
strUser = DLookup("Nama", "Employees", "[UserName]='" & Me.cboUser.Value & "'")

I'm not familiar with VB, so every help is appreciated
 
I guess you could also set the default value to the DLookup() so that it avoided those whole shenanigans?
 

Users who are viewing this thread

Back
Top Bottom