Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Do I need DLookup? or..... 1

Status
Not open for further replies.

gusbrunston

Programmer
Feb 27, 2001
1,234
0
0
US
Hi:

Thanks for your attention to this post.

I am not familiar with the use of
Code:
DLookup
. Perhaps I need it or if you can help with the VBA for the following:

I use a form to post voided checks to a check register (checks mis-printed, etc.).

The form works very well, but it requires the user to input the original amount of the check. If an there is an input error, the check register is incorrect by the amount of the error.

I would like the form to find the payment amount of the original check and populate the control bound to the voided check amount.

The data source for the form is a query of tblOne.

The original check is a record in tblTwo.

In pigeon basic, this is what I need to do:
Code:
Private Sub txtVoidCheckNo_AfterUpdate()
   'Find "VoidCheckNo" in tblTwo
   '(where it's name is "CheckNumber"
Code:
How?
Code:
   'Populate txtDepAmt with the PaymentAmount
   'of the original check found above.
   Me.txtDepAmt = PaymentAmount of original check
End Sub

I've tried to make this as clear as possible. Let me know if additonal info is required.

Thanks greatly, Gus Brunston [glasses] An old PICKer, using Access2000.
 
Gus:

I think this is what you are looking for. Assuming the check number is always a number.

Dim lCheckNumber As Long
Dim vPaymentAmount As Variant
Dim sLookupString As String

If IsNull(Me.txtVoidCheckNo) = False Then

lCheckNumber = Me.txtVoidCheckNo

sLookupString = "[CheckNumber]=" & lCheckNumber

vPaymentAmount = DLookup("[PaymentAmount]", "[Table2]", sLookupString)

Me.txtDepAmt = Format$(vPaymentAmount, "currency")

Else

MsgBox "Please Enter a Check Number", vbInformation

End If
 

Dear TerpFan2001:

Wow! Works like a dream! This will be my DLookup paradigm.
Thanks so much. Gus Brunston [glasses] An old PICKer, using Access2000.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top