Discussion Locked

Access 2000 VB question

0 helpful
9 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

This is my code:
If Me![ClientNum] = DLookup("ClientNum", "ZParPay") Then
Me![Highlight01].Visible = True
End If

The code is supposed to highlight a label
on a form to alert the user that a partial
payment was made on the account and to then
inquire to the client if they wish to make
another deposit or final payment on that
account.

The problem I am having is that the Dlookup
underlying query does not requery for each
record moved to.

Would appreciate some help to make DLookup
to requery for each client number. I know
it is not doing this as I made an unbound field
that is directly related to the DLookup and
that field remains the same for every client
after the first one meets that evaluation.

Thanks

9 replies

by john_wills

I think you misunderstand DLookUp. What you probably need is something like this:
DLookup("[SomethingPaid]", "ZParPay", "[ClientNum]=" & me.ClientNum)
This will yield null if there is no row for that ClientNum and whatever you have in the column SomethingPaid if there is a row for that ClientNum.

by moudoku

The answer you gave does similar to what I already have.
The issue is that I need to get the code to re-evaluate
each and every record on the list, not just the first one
and the save those results for each successive record.

Thanks anyway

by dsa

Add field requery to your code:

If Me![ClientNum] = DLookup("ClientNum", "ZParPay") Then
Me![Highlight01].Visible = True
me![ClientNum].requery
End If

by john_wills

If what I showed you in Answer 1 does not work then you are not reassigning Me.ClientNum: the problem lies elsewhere in your code, perhaps in a loop structure, and I can give no advice without seeing more code. You need in some sense - I am not surejust what sense - to refresh Me.ClientNum. MsgBox Me.ClientNum should let you do a perhaps enlightening trace.

by whyong

you didn't put the "else statement" in it, so if your first record = true then for all your subsequence records, Me![Highlight01] will be visible...
(if i'm not mistaken, the dlookup the you used will only look for the "first record" in the table, dlookup statement in the answer 1 should be the correct statement..)

This discussion is closed to new replies.