Hello everyone,
I have a query that I want to take its criteria from a text box (which is a form).
The user shall put data into the box, hit the "calculate" button and get his result.
The query works just fine when I enter my data in the box and open the query "manually". On pressing the button, however, the query window opens, but is empty. So something must be wrong with my event procedure.
This is the query "qryPriceCalculator":
SELECT...
FROM...
WHERE (((Clients.CNumber)=[Forms]![frmPriceCalculator]![boxCNumber]) AND ((Products.PNumber)=[Forms]![frmPriceCalculator]![boxPNumber].[Text]));
And this is the event procedure:
Private Sub CmdCalc_Click()
DoCmd.OpenQuery "qryPriceCalculator"
End Sub
As I said, this opens the query, but doesn´t give a result.
I also tried running the query directly in VBA, but I can´t get the reference to the text boxes right (CNumber is numeric, PNumber is a text string):
Private Sub CmdCalc_Click()
Dim strSQL As String
strSQL = "SELECT... FROM... WHERE (((Clients.CNumber)=Me.boxCNumber.value) AND ((Products.PNumber)='Me.boxPNumber.value'));"
DoCmd.OpenQuery strSQL
End Sub
Does anyone have a clue what´s wrong with my procedure? Or can help me out with the latter statement?
Thanks a lot,
moori
I have a query that I want to take its criteria from a text box (which is a form).
The user shall put data into the box, hit the "calculate" button and get his result.
The query works just fine when I enter my data in the box and open the query "manually". On pressing the button, however, the query window opens, but is empty. So something must be wrong with my event procedure.
This is the query "qryPriceCalculator":
SELECT...
FROM...
WHERE (((Clients.CNumber)=[Forms]![frmPriceCalculator]![boxCNumber]) AND ((Products.PNumber)=[Forms]![frmPriceCalculator]![boxPNumber].[Text]));
And this is the event procedure:
Private Sub CmdCalc_Click()
DoCmd.OpenQuery "qryPriceCalculator"
End Sub
As I said, this opens the query, but doesn´t give a result.
I also tried running the query directly in VBA, but I can´t get the reference to the text boxes right (CNumber is numeric, PNumber is a text string):
Private Sub CmdCalc_Click()
Dim strSQL As String
strSQL = "SELECT... FROM... WHERE (((Clients.CNumber)=Me.boxCNumber.value) AND ((Products.PNumber)='Me.boxPNumber.value'));"
DoCmd.OpenQuery strSQL
End Sub
Does anyone have a clue what´s wrong with my procedure? Or can help me out with the latter statement?
Thanks a lot,
moori