Hello everyone,
Now I have searched this and other forums for days but cannot get my Dlookup function to work.
Here's what I'm trying to do:
I have 3 tables, one called Staff_List, another called Question_Form and a third called Questions.
The first contains information about our staff, the fields I use for this DB are [Full Name] and [Current Manager]. **I know that using spaces is wrong but the list is updated monthly and comes from an excel spreadsheet.
Basicaly I have a form with a combo box. This box allows the user to chose which staff member is calling, the source of the combo box is in the Staff_list table and the result is stored in another table called Questions.
What I want to do is automaticaly add the agent's manager's name to a field in the Questions table whenever the user selects the agent from the combo box.
The best way I have found so far is to use the Dlookup function.
Right now what I have is an "Afterupdate event" that initiates the Dlookup and hopfully returns it to the Questions table.
Here is my code :
Private Sub CSS_AfterUpdate()
Dim txtManager As String
txtManager = DLookup("[Current Manager]", "Staff_list", "[Full Name] = ' " & CSS & "'")
End Sub
txtManager is a temporary txt box that I put on my form, it is linked to a field called [manager] in my Questions form. CSS is the name of my combobox with the agent names.
I hope I've been clear enough, if not i'll try to clarify.
Thank you!
Now I have searched this and other forums for days but cannot get my Dlookup function to work.
Here's what I'm trying to do:
I have 3 tables, one called Staff_List, another called Question_Form and a third called Questions.
The first contains information about our staff, the fields I use for this DB are [Full Name] and [Current Manager]. **I know that using spaces is wrong but the list is updated monthly and comes from an excel spreadsheet.
Basicaly I have a form with a combo box. This box allows the user to chose which staff member is calling, the source of the combo box is in the Staff_list table and the result is stored in another table called Questions.
What I want to do is automaticaly add the agent's manager's name to a field in the Questions table whenever the user selects the agent from the combo box.
The best way I have found so far is to use the Dlookup function.
Right now what I have is an "Afterupdate event" that initiates the Dlookup and hopfully returns it to the Questions table.
Here is my code :
Private Sub CSS_AfterUpdate()
Dim txtManager As String
txtManager = DLookup("[Current Manager]", "Staff_list", "[Full Name] = ' " & CSS & "'")
End Sub
txtManager is a temporary txt box that I put on my form, it is linked to a field called [manager] in my Questions form. CSS is the name of my combobox with the agent names.
I hope I've been clear enough, if not i'll try to clarify.
Thank you!