Reputation: 131
I have a Tasks tabulated form that contains a combobox for the priority listing of the task. The combobox has the row source tied to a Priority table. I have the combo box working so it displays the correct text of "Urgent, High, etc." based on the Task and Priority tables relationship.
What I would like to do is instead of a combobox for the displayed priority I'd like it to be a textbox. This is where I have problems.
How can I do this for a tabulated form and/or which fields do I need to change to accomplish this?
I have tried settings the textbox:
Control Sources = [Priority]![Priorities]
this gives #Error in the
textboxDefault Value = [Priority]![Priorities]
this also gives #Error in
the textboxControl Source = DLookUp("[Priorities]","[Priority]","[ID]="&[Tasks]![Priority])
this gives #Name? in the textboxDefault Value = DLookUp("[Priorities]","[Priority]","[ID]="&[Tasks]![Priority])
this also gives #Name? in the textboxControl Source = Priority
gives the number lookup for the relationship between the Tasks and Priority tablesThis one works but it is noticeably slow. Is there are "faster", better, way of doing this.
Control Source =DLookUp("Priorities","Priority","ID=" & [Priority])
Upvotes: 0
Views: 1146
Reputation: 21370
Why do you want a textbox? Still need a combobox to select the priority.
Is the form bound to Task table? Cannot reference the Priority table in the textbox Control Source or Default Value. A DLookup will not work in Default Value. DLookup in the Control Source should work.
Simpler approach is to set form Record Source to an SQL statement with left or right join that will 'include all records from Task and only those from Priority that match'. Bind textbox to the descriptive Priorities field from Priority. Set the textbox as Enabled No and Locked Yes so users cannot edit it.
If purpose is to mask/hide the ID then set the combobox as multi-column pulling the required fields with its RowSource SQL and hide the ID column by setting its width to 0. Or don't save the Priority ID, save the actual descriptive value. With very short descriptors and/or small databases that can be justified.
Upvotes: 2