sql - #Error in text boxes controlled by a combo box, but only when a certain value is entered in the combo -


i have text box controlling combo box in turn controlling 4 text boxes.

the first text box filled user or append query 4 digit store number.

the combo box populated following query.

select vendors.ip vendors (((vendors.store)=[forms].[project details].[store])); 

that combo box populates text boxes.

=dlookup("ipphone","vendors","ip='" & [forms]![project details]![cboip] & "'") 

"ipphone" 4 separate values (1 each text box) redacted simplicity. dlookup works vendors.

but there 1 not seem weird @ all, call him "mr mctrouble". when selected drop down 4 text boxes show "#error". he's 1 of 400 vendors cause this. i've tried deleting him using forms created , re-entering him. tried doing in end table itself, no luck. him boxes show #error.

the combo box vendor name drawn table following fields:

store    vendor    ip            ipphone 1111    000001    john johnson   111-111-1111 2222    000002    mike           111-111-1112 2222    000003    frankie frank  111-111-1113 3333    000004    joe bob        111-111-1114 4444    000005    smith smith    111-111-1115 5555    000006    mr mctrouble   111-111-1116 

date types on table are:

number  number    text            text 

the other fields here populate text boxes.

what missing here?

is there easier way this?

there single quote in vendor's name, o'donnell or o'malley. code builds sql clause uses single quotes, resulting in improperly formatted string looking this: ip='o'malley'

try:

=dlookup("ipphone","vendors","ip=""" & [forms]![project details]![cboip] & """") 

i replaced each single quote 2 double quotes. in vba, weird way double-quotes escaped.

a better solution, assuming vendor primary key vendor.

  • combo rowsource: select vendors.vendor,vendors.ip [... rest of sql]
  • combo columncount: 2
  • combo columwidths: 0;1.5 (the 0 hides first column in combo)
  • =dlookup("ipphone","vendors","vendor=" & [forms]![project details]![cboip])

primary keys should used lookup values, if available.


Comments