![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have the following tables 1. tblActivities 2. tblEmpName with the fields IDNum and EmpName 3. tblTradeWorked with the fields WorkedFor and TradeWithIDNum I have a main form frmEmpForm with a subform frmActivities. The main form has a control button that is used to open frmTradeWorked. When I enter a name in the control WorkedFor on the frmTradeWorked which gets EmpName from tblEmpName, I want the control on the frmTradeWorked entitled TradeWithIDNum to autofill with the correct IDNum from the tblEmpName. This is the code I am trying to use but it will not work. Private Sub WorkedFor_AfterUpdate() Me.TradeWithIDNum = DLookup("[IDNum]", "tblEmpName", "[EmpName]='" & Me.[WorkedFor] & "'") End Sub Help is appreciated Thanks Ron |
#3
| |||
| |||
|
|
I have the following tables 1. tblActivities 2. tblEmpName with the fields IDNum and EmpName 3. tblTradeWorked with the fields WorkedFor and TradeWithIDNum I have a main form frmEmpForm with a subform frmActivities. The main form has a control button that is used to open frmTradeWorked |
|
When I enter a name in the control WorkedFor on the frmTradeWorked which gets EmpName from tblEmpName, I want the control on the frmTradeWorked entitled TradeWithIDNum to autofill with the correct IDNum from the tblEmpName. This is the code I am trying to use but it will not work. Private Sub WorkedFor_AfterUpdate() Me.TradeWithIDNum = DLookup("[IDNum]", "tblEmpName", "[EmpName]='" & Me.[WorkedFor] & "'") End Sub Help is appreciated Thanks Ron |
#4
| |||
| |||
|
|
I have the following tables 1. tblActivities 2. tblEmpName with the fields IDNum and EmpName 3. tblTradeWorked with the fields WorkedFor and TradeWithIDNum I have a main form frmEmpForm with a subform frmActivities. The main form has a control button that is used to open frmTradeWorked. When I enter a name in the control WorkedFor on the frmTradeWorked which gets EmpName from tblEmpName, I want the control on the frmTradeWorked entitled TradeWithIDNum to autofill with the correct IDNum from the tblEmpName. This is the code I am trying to use but it will not work. Private Sub WorkedFor_AfterUpdate() Me.TradeWithIDNum = DLookup("[IDNum]", "tblEmpName", "[EmpName]='" & Me.[WorkedFor] & "'") End Sub Help is appreciated Thanks Ron |
#5
| |||
| |||
|
|
"A_Classic_Man" <rmerk... (AT) cox (DOT) net> wrote in message news:da6efdec-900c-4d2f-a4cf-f8ed2e08a097 (AT) u32g2000yqe (DOT) googlegroups.com... I have the following tables 1. tblActivities 2. tblEmpName with the fields IDNum and EmpName 3. tblTradeWorked with the fields WorkedFor and TradeWithIDNum I have a main form frmEmpForm with a subform frmActivities. The main form has a control button that is used to open *frmTradeWorked. When I enter a name in the control WorkedFor on the frmTradeWorked which gets EmpName from tblEmpName, I want the control on the frmTradeWorked entitled TradeWithIDNum to autofill with the correct IDNum from the tblEmpName. This is the code I am trying to use but it will not work. Private Sub WorkedFor_AfterUpdate() Me.TradeWithIDNum = DLookup("[IDNum]", "tblEmpName", "[EmpName]='" & Me.[WorkedFor] & "'") End Sub Help is appreciated Thanks Ron It's a syntax problem. If you're going to use square brackets: [WorkedFor] it must be with the bang, not the dot, ie: Me![WorkedFor] However, since WorkedFor doesn't contain any spaces, you don't need the brackets anyway (the same goes for IDNum and EmpName), so: Me.TradeWithIDNum = DLookup("IDNum", "tblEmpName", "EmpName='" & Me.WorkedFor & "'") should do nicely.- Hide quoted text - - Show quoted text - |
#6
| |||
| |||
|
|
On Jan 19, 12:15*am, "Stuart McCall" <smcc... (AT) myunrealbox (DOT) com> wrote: "A_Classic_Man" <rmerk... (AT) cox (DOT) net> wrote in message news:da6efdec-900c-4d2f-a4cf-f8ed2e08a097 (AT) u32g2000yqe (DOT) googlegroups.com.... I have the following tables 1. tblActivities 2. tblEmpName with the fields IDNum and EmpName 3. tblTradeWorked with the fields WorkedFor and TradeWithIDNum I have a main form frmEmpForm with a subform frmActivities. The main form has a control button that is used to open *frmTradeWorked. When I enter a name in the control WorkedFor on the frmTradeWorked which gets EmpName from tblEmpName, I want the control on the frmTradeWorked entitled TradeWithIDNum to autofill with the correct IDNum from the tblEmpName. This is the code I am trying to use but it will not work. Private Sub WorkedFor_AfterUpdate() Me.TradeWithIDNum = DLookup("[IDNum]", "tblEmpName", "[EmpName]='" & Me.[WorkedFor] & "'") End Sub Help is appreciated Thanks Ron It's a syntax problem. If you're going to use square brackets: [WorkedFor] it must be with the bang, not the dot, ie: Me![WorkedFor] However, since WorkedFor doesn't contain any spaces, you don't need the brackets anyway (the same goes for IDNum and EmpName), so: Me.TradeWithIDNum = DLookup("IDNum", "tblEmpName", "EmpName='" & Me.WorkedFor & "'") should do nicely.- Hide quoted text - - Show quoted text - Thanks to all for the responses Stuart, I tried your suggestion and still get nothing. The IDNum fields are text fields and are size is set to 5 for both fields. TradeWithIDNum in the tblTradeWorked and IDNum in the tblEmpName are the linked fields. I have checked spelling of table and field names and all appear to be correct. Any other ideas what to look for. I have a feeling there is something simple that I am missing Ron- Hide quoted text - - Show quoted text - |
#7
| |||
| |||
|
#8
| |||
| |||
|
|
The working code is exactly what I posted. Oh well, blame the gremlins. Stuart |
![]() |
| Thread Tools | |
| Display Modes | |
| |