Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
hi,
biulding the sports database still.(office/wwwboard/forum/4630.html)I am building a form based on a table. I am trying to :
1. grab the selection made from a combo box(Event Name)
2.compare it to a field in a table (EventsDetail)
3.Return the matching Event id from the table.
I tried Dlookup - maybe I am doing something wrong.can any1 help?
=DLookUp("[EventID_tbl]","EventsDetail","[EventName_tbl] =[Combo22] "))
combo22 is the "EventName" selection combo box.

hi
thnx. i fixed the paranthesis..to no avail. it now comes up with #erroralso, even tho' the event name is listed, it won't get choosen..any idea why?

Are you putting this in the control source of something? If so, there is no error checking. I would suggest to put this in an event procedure (code) so that it does error checking for you. It can be on the 'after update' property of the combo box. You can even put the stop command right after the dlookup command to check the value you get via the immediate window. Once you get it down right, you can then copy the dlookup command to the control source.

the combo box that lists the event names is just listing them, I can scroll thru the list but when I click on one of entries in the list, nothing happens.
I need to fix the above, before trying to put the =DLookUp("[EventID_tbl]","EventsDetail","[EventName_tbl] =[Combo22] ") in after update of the combo box.( I don't understand why I have to put this in the combo box..I am trying to get the value in a txt box.) also, what is the stop command? I am a beginner, so don't know about code building either

I only want you to run this as code someplace since it can error check for you. It is very useful to troubleshot issues like this. The stop command just stops the code from running at that point. You can then open what is called an immediate window to check any values in the code. If for instance your dlookup command returns the wrong value, you can actually retype the dlookup command as many times as you want in the immediate window until you get the right value.
I only chose the combo box since I thought you needed to pick something from the combo box before getting the value with dlookup. I understand you want the value stored in a text box.
The code would simply be something like this:
[textboxname]=DLookUp("[EventID_tbl]","EventsDetail","[EventName_tbl] =[Combo22] ")
It is getting late here. I will check back later tomorrow.

There are a few issues here.
1) It appears to me that the DLookup function is referencing a table in the where clause that is different then the domain you entered.2) [Combo22] should not be contained within the string. You need to close the string after the = sign and then add '& [combo22])' without the quotes of course.
3) Yes, the dlookup function would be in the text box not the combo box.
4) You need to put the code
Forms!FormName.Refresh in the after update event of the combobox.5) You need to add the Nz function to your textbox to handle when there is no value in the combobox, for example =Nz(dlookup(...))

thanks guys.
managed to fix it. fiddled around along the lines of the advice. it needed the refencing fixed.
thnx again.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |