Solved

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

Posted on 2014-07-21
5
419 Views
Last Modified: 2014-07-22
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
Comment
Question by:fordraiders
  • 3
  • 2
5 Comments
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 40210157
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
 
LVL 3

Author Comment

by:fordraiders
ID: 40210181
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
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 total points
ID: 40210211
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
 
LVL 3

Author Closing Comment

by:fordraiders
ID: 40210821
Thanks for the information
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 40210946
glad to help.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now