Using Dlookup

Cereldine

Registered User.
Local time
Today, 11:29
Joined
Aug 4, 2005
Messages
71
Can you use dLookup to look into a table if a record in it doesnt exist?
A summary of what im trying to do.
The admin guy can view a invoice and its breakdown, there may be many invoices for each application. In the form footer is a button that allows the admin to make a payment ( insert sql into payments table)
What i want is for code to check if that particular invoice has been paid, if it has show a label stating so, if not show the payment button.

Ive been trying this but receive error 3464.

Dim iInvoice As String
iInvoice = Me.invoices_id
Dim iResult As Variant
iResult = Nz(DLookup("[payment_amt]", "temp_payments_table", "[Invoice_id] = '" & iInvoice & "' "))

If iResult > 0 Then
Me!sub_payments_invoice_works.Form!sub_payment_works_total!Form!lblPaid.Visible = True
Else
Me!sub_payments_invoice_works.Form!sub_payment_works_total!Form!cmdPayment.Visible = True
End If

Ive only really experimented with dlookup yesterday so relativly new to me, can you include NZ with it? How can i fix my problem, thanks.
 
Code:
if isnull(DLookup("[payment_amt]", "temp_payments_table", "[Invoice_id] = '" & Me!invoices_id & "' ")) then
    Me!sub_payments_invoice_works.Form!sub_payment_works_total!Form!lblPaid.Visible = True
Else
    Me!sub_payments_invoice_works.Form!sub_payment_works_total!Form!cmdPayment.Visible = True
End If

???
 
the above method does not appear to work either, i keep getting same error msg
 
Am I guessing correctly that Invoice_ID in the temp_payments_table is a text string and not a numeric???
 
Then maybe:

Code:
if isnull(DLookup("[payment_amt]", "temp_payments_table", "[Invoice_id] = " & Me!invoices_id )) then
    Me!sub_payments_invoice_works.Form!sub_payment_works_total!Form!lblPaid.Visible = True
Else
    Me!sub_payments_invoice_works.Form!sub_payment_works_total!Form!cmdPayment.Visible = True
End If
???
 

Users who are viewing this thread

Back
Top Bottom