Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 449
  • Last Modified:

Textbox controlsource is a query but not showing results jUST $ Name

Access 2010
Useform with textbox , combobox(2 columns--bound to column2, query
What I need: Trying get the textbox to display a value from the query but a criteria is also a value from a combobox.

=DLookUp("CountOfProcrun","xaEmployee_Wwg_Searches","RACF=" & [Forms]![iData_Reporting]![combo5])
or
SELECT Count(dbo_iData_Desc_Search_Log.ProcRun) AS CountOfProcRun
FROM dbo_iData_Desc_Search_Log
GROUP BY dbo_iData_Desc_Search_Log.RACF, dbo_iData_Desc_Search_Log.ProcRun
HAVING (((dbo_iData_Desc_Search_Log.RACF)=[Forms]![iData_Reporting]![Combo5]) AND ((dbo_iData_Desc_Search_Log.ProcRun)="1"));



this is not working ?

Thanks
fordraiders
0
Fordraiders
Asked:
Fordraiders
  • 3
  • 2
1 Solution
 
Dale FyeCommented:
Is the textbox on Forms!iData_Reporting?

I assume that [Combo5] (really bad name for a control, BTW)  bound to a data field on the form, or us just used for this and other purposes?

If so, have you tried:

DLookUp("CountOfProcrun","xaEmployee_Wwg_Searches","RACF=" & [Forms]![iData_Reporting]![combo5])

Have you considered just putting the code in the afterupdate event of the combo box?  That way, you could test to see whether it is a valid entry, or is empty, and then handle the situation appropriately.

Private Sub combo5_AfterUpdate

    dim strCriteria as string

    if TRIM(me.combo5 & "") <> "" Then

        'if the combo bound column is numeric, use this
        strCriteria = "RACF=" & me.[combo5]

        'if the combo bound column is text, use this
        strCriteria = "RACF='" & me.[combo5] & "'"
   
        me.SomeOtherControl = DLOOKUP("CountOfProcrun","xaEmployee_Wwg_Searches",strCriteria)

    end if

End Sub

Open in new window

0
 
FordraidersAuthor Commented:
FYED,  [Combo5]  is bound a table with 2 columns... But the value i need the query is the 2 nd  column.

BILL THOMAS |  BR2QW2

so if i select "BILL THOMAS"  I NEED THE QUERY TO USE  "BR2QW2"
0
 
Dale FyeCommented:
The syntax for that is either:

me.combo5.column(1)

OR, if it is not on the same form as the other data:

[Forms]![iData_Reporting].[Combo5].column(1)

The column property of the combo box is zero based, so the first column is referred to using column(0).

My personal preference is to put the bound column as 1 (not zero based) and hide that column from the user, then display what you want the user to see "Bill Thomas" in column 2 of the query.  Then you set the column widths to 0;1.5"

With it configured this way, you could simply refer to [Combo5], since the bound column will contain the value "BR2QW2"
0
 
FordraidersAuthor Commented:
Thanks for the information
0
 
Dale FyeCommented:
glad to help.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now