Return a value from a select query

Gannet

Registered User.
Local time
Today, 03:57
Joined
Sep 21, 2006
Messages
55
I have several combo boxes that I use to select parameters for a query. I have the query that works perfectly but I can't figure out how to set the value to another textbox. I have included the sql statement below.

SELECT DISTINCT grades.term, grades.category, grades.[_AE_Supra_ordinate_Term], grades.[_Select_AE] FROM grades WHERE (((grades.category)=[forms]![frmAE].[category]) AND ((grades.[_AE_Supra_ordinate_Term])=[forms]![frmAE].[_AE_Supra_ordinate_Term]));
 
Put the result in a recordset.
Code:
    Dim rst       As Recordset
    Dim qdf       As QueryDef
        
    Set qdf = CurrentDb.QueryDefs(strQry)
    Set rst = qdf.OpenRecordset
    
    do While not rst.eof
         me.txtbox1.value = rst.fields(0)
         me.txtbox2.value = rst.fields("grades.term")
         rst.movenext
    loop
more or less.

HTH Guus
 
Not sure what to do with code but got this to work.

I put this code in the "OnChange" event of frm.grades field

Me.term.RowSource = "SELECT DISTINCT grades.term FROM grades WHERE (((grades.category)=forms!frmAE.category) And ((grades.[_AE_Supra_ordinate_Term])=forms!frmAE.[_AE_Supra_ordinate_Term]) And ((grades.[_Select_AE])=Forms!frmAE.[_Select_AE]));"

Me.term.Requery
Me.term.Value = Me.term.ItemData(0)

Worked well but I thought there might be a more direct way of doing this.
 

Users who are viewing this thread

Back
Top Bottom