Hi All
I've got a form where I'm trying to display the results of an SQL query in a textbox by clicking a button. See code below that I'm trying but doesn't work, not geting an error messages the result just isn't displaying in Text51 when I Click the FindCommission_Ref button. The result I want is the Comissioning_Ref from the Comossioning table and will be got from 2 comboboxes(Combo27 & Combo31) where Commissioning.Doc_Ref = Commissioning.Vehicle_No
Any help would be much appreciated on thisPrivate Sub FindCommission_Ref_Click() Dim strSQL As String strSQL = "SELECT Commissioning.Commission_Ref FROM Commissioning WHERE (((Commissioning.Doc_Ref)=[Forms]![Commissioning]![Combo27]) AND ((Commissioning.Vehicle_No)=[Forms]![Commissioning]![Combo31]));" DoCmd.RunSQL strSQL Me.Text51 = strSQL End Sub
Donal
Last edited by pike; 07-05-2010 at 09:11 AM. Reason: add code tags for newbie mp message
You could use a Domain Aggregate function:
I'm not sure what data type your combos are (Combo27 and Combo31), so if they are text use:
If they are numeric use:Me.Text51 = Dlookup("Commission_Ref","Commissioning","Doc_Ref='" & [Forms]![Commissioning]![Combo27] & "' AND Vehicle_No='" & [Forms]![Commissioning]![Combo31] & "'")
Me.Text51 = Dlookup("Commission_Ref","Commissioning","Doc_Ref=" & [Forms]![Commissioning]![Combo27] & " AND Vehicle_No=" & [Forms]![Commissioning]![Combo31])
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks