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

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Forum statistics

Threads
1,223,229
Messages
6,170,881
Members
452,364
Latest member
springate

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