David Ball
Registered User.
- Local time
- Tomorrow, 02:12
- Joined
- Aug 9, 2010
- Messages
- 230
Hi,
I have a report (rptTESTInfoBySubsystem) based on a query. I want to be able to enter a Subsystem number (e.g. 4302-023-500) into a textbox (TxtSubsystem) on a form, and click on a command button (CmdSubsystem) on the same form to have the report opened and show only results for Subsystem 4302-023-500. The field in the query is called Subsystem.
The code below does not work. It just opens the Report with no data.
If I reference a different field (e.g. Description) and enter a text value that occurs in that field (e.g. Motor) into the textbox it works.
Why does it not work for field Subsystem when I enter 4302-023-500 in the textbox? (It works if I enter 4302-023-500 as a criteria directly in the query).
Code:
Private Sub CmdSubsystem_Click()
DoCmd.OpenReport "rptTESTInfoBySubsystem", acViewReport, , " Subsystem = " + TxtSubsystem.Value
End Sub
I’ve also tried including the query name in the Filter section as below, still doesn’t work:
Private Sub CmdSubsystem_Click()
DoCmd.OpenReport "rptTESTInfoBySubsystem", acViewReport, "qryTestDetailsBySubsystem", " Subsystem = " + TxtSubsystem.Value
End Sub
Thanks very much
I have a report (rptTESTInfoBySubsystem) based on a query. I want to be able to enter a Subsystem number (e.g. 4302-023-500) into a textbox (TxtSubsystem) on a form, and click on a command button (CmdSubsystem) on the same form to have the report opened and show only results for Subsystem 4302-023-500. The field in the query is called Subsystem.
The code below does not work. It just opens the Report with no data.
If I reference a different field (e.g. Description) and enter a text value that occurs in that field (e.g. Motor) into the textbox it works.
Why does it not work for field Subsystem when I enter 4302-023-500 in the textbox? (It works if I enter 4302-023-500 as a criteria directly in the query).
Code:
Private Sub CmdSubsystem_Click()
DoCmd.OpenReport "rptTESTInfoBySubsystem", acViewReport, , " Subsystem = " + TxtSubsystem.Value
End Sub
I’ve also tried including the query name in the Filter section as below, still doesn’t work:
Private Sub CmdSubsystem_Click()
DoCmd.OpenReport "rptTESTInfoBySubsystem", acViewReport, "qryTestDetailsBySubsystem", " Subsystem = " + TxtSubsystem.Value
End Sub
Thanks very much