Dlookup problem

mba_110

Registered User.
Local time
Today, 10:42
Joined
Jan 20, 2015
Messages
280
Hi

I have form where i am trying to call the image based on combo box selection its employee image.

1. Field Name EmpID is number field.

2. Field name Picture is text field which hold the file path of employee on computer.

my code is below but its showing data type mismatch error "3464"

Code:
Private Sub cboEmpID_AfterUpdate()
image.Picture = Nz(DLookup("[picture]", "tblEmployees", "[EmpID]='" & Me.cboEmpID.Value & "'"), "")

End Sub

thanks & regards,
MA
 
That code is for a text field. Change it to:

Code:
Private Sub cboEmpID_AfterUpdate()
image.Picture = Nz(DLookup("picture", "tblEmployees", "EmpID=" & Me.cboEmpID), "")

End Sub

NOTE:
[] brackets not required as your field names do not contain spaces or special characters.
.Value not needed as its the default property
 
Are you using Access 2007 or later? VBA is not needed. Can use ControlSource property to load image. [picture] field can be a column of combobox then Image control references combobox column index. Column 2 would be index 1.

=[cboEmpID].Column(1)

Or the DLookup can be in ControlSource.
 
Last edited:
Thanks for your reply that is ok.

now i am trying to call employee name based on combo selection on form

Fullname field is text in tblEmployees


my code on form current event is

Code:
Me.Name = Nz(DLookup("Fullname", "tblEmployees", "EmpID='" & Me.cboEmpID & "'"), "")

it is also showing same issue data type mismatch...please help.


thanks & regards,
MA
 
That will likely be as you have not taken note of Ridders reply.?

If the search criteria is text, you use ', else you do not.


Code:
Me.Name = Nz(DLookup("Fullname", "tblEmployees", "EmpID=" & Me.cboEmpID), "")
Thanks for your reply that is ok.

now i am trying to call employee name based on combo selection on form

Fullname field is text in tblEmployees


my code on form current event is

Code:
Me.Name = Nz(DLookup("Fullname", "tblEmployees", "EmpID='" & Me.cboEmpID & "'"), "")
it is also showing same issue data type mismatch...please help.


thanks & regards,
MA
 
You should really use June's solution here.

Pull all the employee information you need into hidden columns on the combo box.
Set your controls to use the hidden column data as their control source.

I do hope you aren't storing all this information into fields in a related record, and that is simply for display purposes.... ?
 

Users who are viewing this thread

Back
Top Bottom