By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,488 Members | 2,545 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,488 IT Pros & Developers. It's quick & easy.

Runtime error 3075

P: 4
Hi, i'm trying to perform a Dlookup on a combo box in a form using the after update event, this is what ive got:
Rate=Dlookup("Rate" , "OperativeTypeT","Operative_Type=" & Operative_Type)

Can someone tell me where i'm going wrong as I keep getting runtime 3075 error saying i'm missing an operator in my expression
Jan 5 '12 #1
Share this Question
Share on Google+
6 Replies


Expert Mod 2.5K+
P: 2,545
In the Where clause (the third parameter) of the DLookup, if the field Operative_type is a text value you need to enclose the value concerned in single quotes, like this:

Expand|Select|Wrap|Line Numbers
  1. Rate=Dlookup("Rate" , "OperativeTypeT","Operative_Type = '" & Operative_Type & "'")
-Stewart
Jan 5 '12 #2

P: 4
Thanks Stewart, but now when I run the expression when I change the operative type in the combo box it only displays the first rate in the list, it doesnt change when i change the combo box value, justa stays with the same value
Jan 5 '12 #3

Expert Mod 2.5K+
P: 2,545
I cannot tell without access to your tables why the problem you are experiencing is happening, so I think it will take some detailed debugging from you to resolve it.

I can only suggest that you set a breakpoint in the AfterUpdate sub and ensure that the AfterUpdate event is being triggered correctly for the combo concerned, and if so step through the lines one by one, tracing the value of the Dlookup as it is executed.

-Stewart
Jan 5 '12 #4

P: 4
Hi Stewart, is it possible you could take a quick look at the DB for me to see where I am going wrong, heres the link for the file:
http://www.mediafire.com/?i182gxwp8dp49vo

Thanks

Antony
Jan 6 '12 #5

Expert Mod 2.5K+
P: 2,545
The problem was in the Where clause of the DLookup, in which you had the name of the field as Operative_Type. The real name of the field is Operative Type, and as it has a space in it it has to be delimited by square brackets when used in the where clause.

The revised version of your Dlookup for rate is as follows:

Expand|Select|Wrap|Line Numbers
  1. Rate = DLookup("Rate", "OperativeTypeT", "[Operative Type] = '" & Operative_Type & "'")
It is possible to do away with the lookup altogether, by including the rate in the query feeding the combo box, increasing the number of columns in the combo to 2, hiding the second column, and using the Columns property of the combo to update the rate from the AfterUpdate event. I have done this in the attached version (which is compressed into a zip file), so you have a choice of either fixing the original issue and leaving it at that, or using the rate directly from the combo box. The choice is yours.

-Stewart
Attached Files
File Type: zip Databaseant.zip (57.7 KB, 29 views)
Jan 6 '12 #6

P: 4
Thanks for all your help Stewart

Regards

Antony
Jan 7 '12 #7

Post your reply

Sign in to post your reply or Sign up for a free account.