Dlookup and treatment of "space" in Access names

Jubinell

Board Regular
Joined
Jan 17, 2008
Messages
166
Hi,

I have a specific question and a general question.

The specific question is this:

I currently have a form with two comboboxes called "Combo Case Code" and "Combo Case Name." I've linked the values to a query that retrieves values for fields called "Case Code" and "Case Name" in a table called "tbl Case Codes and Names".

I'm trying to write an after_update sub procedure that updates the Case Name Combobox with the corresponding Case Code provided in the Case Code Combo box. The code I have is the following:

Code:
Private Sub Combo_Case_Code_AfterUpdate()
Combo_Case_Name = DLookup("[Case Name]", "tbl Case Codes and Names", "[Case Code]=' " & Combo_Case_Code & " ' ")
End Sub
I get the "Invalid Procedure Call or Argument" error message. How can I make this lookup work?

I suspect the error comes from sloppy name formatting in my code above, which leads me to my general question. How does Access treat names with spaces in general? I know that objects on forms with names that have spaces, such as "my textbox" get renamed "my_textbox" in the VBA environment for event procedures. What about tables, forms, table fields and other objects in Access?


Thank you for your help.
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Forum statistics

Threads
1,215,008
Messages
6,122,672
Members
449,091
Latest member
peppernaut

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top