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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

lookup value to display on a report

Status
Not open for further replies.

don2241

IS-IT--Management
Jun 1, 2001
57
AU
Hi!

Sorry about the question with the same name, I clicked on the wrong button.

I have a report that displays data from a query. One of the columns displays a checkbox. I want to lookup a value in a different query and display a value IF THE CHECKBOX IS FALSE (not ticked) under the Managers column. My report has this columns:
ID - Name - Checkbox - Manager

txtSupplier_ID is my textbox name for ID data
txtManager is my textbox for Manager data

This is the code I tried but it does not correspond to the right data.

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

If (Primary = False) Then

Dim first As Variant
Dim last As Variant
Dim manName As Variant
Dim id As Integer

id = txtSupplier_ID.Value

first = DLookup("[FirstName]", "qryReport_lookup", "[Supplier_ID] = " & id)
last = DLookup("[LastName]", "qryReport_lookup", "[Supplier_ID] = " & id)
manName = first & " " & last
txtManager.Value = manName

End If

End Sub

Thanks

M.
 

Why not just set the ControlSource of txtManager to:

=Iif(Primary=False, DLookup ("Firstname", "qryReport_lookup", "[Supplier_ID] = " & txtSupplier_id) & " " & DLookup("Lastname", "qryReport_lookup", "[Supplier_ID] = " & txtSupplier_id)
, <whatever you want for if primary = true>)

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top