Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Check Boxes to Select items to Print

Status
Not open for further replies.

whjwilson

Technical User
Jan 20, 2006
23
0
0
US
I currently have a form I am using to input data into my database. The form itself has a subform on it. The main form itself lists the information on the person, teh subform list all the equipment assigned to this particular person.

I've added a new column on the subform in which users will be able to select which items assigned to this person they want to select, and print the report only with the selected items. I am looking for a way to modify my current code below to accomodate the check box that was added if possible.

DoCmd.OpenReport "Main_Table", acPreview, , "Name = '" & Forms!Main_Table!Name & "'"

Exit_Command38_Click:
 
Apparently you added a field to the record source of the subform. It would really help if you provided the name of the field. Assuming this new field is in the record source of the report, you should be able to use:
Code:
Dim strWhere as String
strWhere = "[Name] = '" & Forms!Main_Table!Name & "' AND [New Column] = -1"
DoCmd.OpenReport "Main_Table", acPreview, , strWhere
BTW: "Name" is a reserved word and possibly the worst NAME that you can give anything in Access since everything has a NAME property and your code may malfunction.

Duane
Hook'D on Access
MS Access MVP
 
The name of the new column is "Selected", it was not in the record source of the report but I added it, and changed the code to:

Dim strWhere As String
strWhere = "[Name] = '" & Forms!Main_Table!Name & "' AND [Selected] = -1"
DoCmd.OpenReport "Main_Table", acPreview, , strWhere

When I run it now I get "Data type mismatch in criteria expression".

Also thanks for the tip on not using "Name", will go thru and change it in my database to "soldier
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top