Imdabaum
01-14-2010, 01:55 PM
Sorry for the double post.
I thought I had hit new topic, but it appears it was new reply.
I'm not exactly sure what I'm doing wrong here, but I'm running into this issue. I have a textbox with a control source as a DLookup. The recordset contains IDs from different tables, and I want the customer name to display in a textbox related to the customer id. Easy enough I thought, but this is what I have/get
'Attempt 1
textbox.ControlSource = DLookUp("CustomerName","TBL_CUSTOMERS","CustomerNumber = '" & Me.CustID & "'")
textbox = #Name? when CustID is null, I thought it was easy enough to handle, using Nz and setting the textbox to an empty string if there was no Customer id
'Attempt 2
textbox.controlSource = Nz(DLookUp("CustomerName","TBL_CUSTOMERS","CustomerNumber = '" _
& Me.CustID & "'"),"")
'I thought this should have given me the customer name or an empty string.
At this point I have tried, =IIF(IsNull(CustID)....) and =IIF(Not IsNull(CustID)... And still the textbox always turns up as #Name?
I tried to evaluate the code in vba and even when CustID is null, it still attempts to evaluate the DLookup instead of just giving me the appropriate value.
I realize that I can set the value of this textbox on Current event, or through VBA using simple If statement, but is there a solution where I can just set the controlsource in design to evaluate it?
I thought I had hit new topic, but it appears it was new reply.
I'm not exactly sure what I'm doing wrong here, but I'm running into this issue. I have a textbox with a control source as a DLookup. The recordset contains IDs from different tables, and I want the customer name to display in a textbox related to the customer id. Easy enough I thought, but this is what I have/get
'Attempt 1
textbox.ControlSource = DLookUp("CustomerName","TBL_CUSTOMERS","CustomerNumber = '" & Me.CustID & "'")
textbox = #Name? when CustID is null, I thought it was easy enough to handle, using Nz and setting the textbox to an empty string if there was no Customer id
'Attempt 2
textbox.controlSource = Nz(DLookUp("CustomerName","TBL_CUSTOMERS","CustomerNumber = '" _
& Me.CustID & "'"),"")
'I thought this should have given me the customer name or an empty string.
At this point I have tried, =IIF(IsNull(CustID)....) and =IIF(Not IsNull(CustID)... And still the textbox always turns up as #Name?
I tried to evaluate the code in vba and even when CustID is null, it still attempts to evaluate the DLookup instead of just giving me the appropriate value.
I realize that I can set the value of this textbox on Current event, or through VBA using simple If statement, but is there a solution where I can just set the controlsource in design to evaluate it?