Dlookup - Afterupdate

rpadminserver

Board Regular
Joined
Nov 7, 2007
Messages
111
Office Version
  1. 365
Hello All.
I'm tring to get Dlookup to work in an AfterUpdate sub. Here is what I have:

Private Sub cmbTKINCONDNUM_AfterUpdate()
If Not IsNull(Me.cmbTKINCONDNUM) Then
Me.Tkincondnum_subform.Form.Filter = DLookup("tkincondnum", "tkincondition", "tkincondnum =" & Me.cmbTKINCONDNUM)
End If
Me.Tkincondnum_subform.Form.FilterOn = True
End Sub

The goal here is to get the subform to filter my records based on the Dlookup.

Thanks
Rob
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
1. You wouldn't be looking up tkincondnum if it is equal to the combo as you could just use the combo's value.

2. You really are needing to loookup something else (perhaps) or if you are looking up tkincondnum then you shouldn't be using itself to identify it:
Code:
tkincondnum = " & Me.cmbTKINCONDNUM
you would use someOTHER field for that criteria.

3. The filter needs the field name and the value. So for this:
Code:
Me.Tkincondnum_subform.Form.Filter

you would need to use

Code:
Me.Tkincondnum_subform.Form.Filter = "[FieldNameHere] = DLookup....etc.


So, the first thing to answer is what is it you are really trying to look up and if it is TKINCONDNUM then why can't you just use
Code:
Me.Tkincondnum_subform.Form.Filter = "[tkincondnum] = " & Me.cmbTKINCONDNUM
 
Upvote 0

Forum statistics

Threads
1,224,505
Messages
6,179,147
Members
452,891
Latest member
JUSTOUTOFMYREACH

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