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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can VB Code be used to UnCheck...a Checkbox that set to True by a user 2

Status
Not open for further replies.

testkitt2

Technical User
Apr 28, 2004
193
US
hello Tipsters

I have a main form that has a subform...in that subform there is a checkbox whereby the user will click and turn the checkbox to yes or true.. this subform is attached to a report that will only print those items that has a checkbox ..checked off. I want to have the checkbox unchecked after the report is printed. thus resetting the subform for the next set of instructions. If you manually uncheck the box...thats fine. but some users forget to uncheck the box even after printing the report.

the main form is called: "unit"
the subform is called: "SubParts"
the checkbox (on the subform) is called: "Print Order"

what I'm trying to do is either create a command button that will uncheck all records that have a checkbox equal to true or when the user prints his report that is based on the checkbox being true that the checkbox becomes false.

Is this possible

Thank you
JZ



Testkitt2
 
If you changed the recordset and that recordset is a parameter query (prompts or tied to form(s)), then you are going to have to supply those parameters somehow, or use a different recordset.

But, like Zion asked, can we see the code and the SQL for your recordset?
 
Good eve to all
I have provide the SQL code as requested...anything else let me know...
The original code worked... but like I said when adding the second query and changing the code a bit..it gave me the error....Too Few Parameters. Expected 3

This is the original query that worked with the code to uncheck the check boxes.
Code:
SELECT Unit.Truck, Unit.[Vin #], Unit.Year, Unit.Make, Unit.Model, PartsDescription.DateLock, PartsDescription.Qty, PartsDescription.[Part No], PartsDescription.[Print Order], PartsDescription.Description, PartsDescription.Technician, PartsDescription.[Truck Status], PartsDescription.Comments, PartsDescription.Quotes, [Qty]*[Quotes] AS TPrice, tbVendor.[tbVendor Name], tbVendor.Address, tbVendor.Tel, tbVendor.Account, PartsDescription.Index
FROM tbVendor, Unit INNER JOIN PartsDescription ON Unit.Truck = PartsDescription.Truck
WHERE (((Unit.Truck)=[Enter Equipment or Stock]) AND ((PartsDescription.[Print Order])=Yes) AND ((PartsDescription.Technician)=[' Enter your first initial and last name to print requisition ']) AND ((tbVendor.[tbVendor Name]) Like [Enter The First Few Characters of the Vendor: ] & "*"));

This is an archive of requisitions that may at one point be re-printed, thus the check box may be checked off to print the order again...but then if left unchecked the code will uncheck all
those check boxes that are left checked off. This is the query that gives me the error.
Code:
SELECT Unit.Truck, Unit.[Vin #], Unit.Year, Unit.Make, Unit.Model, PartsArchived.DateLock, PartsArchived.Qty, PartsArchived.[Part No], PartsArchived.[Print Order], PartsArchived.Description, PartsArchived.Technician, PartsArchived.[Truck Status], PartsArchived.Comments, PartsArchived.Quotes, [Qty]*[Quotes] AS TPrice, tbVendor.[tbVendor Name], tbVendor.Address, tbVendor.Tel, tbVendor.Account, PartsArchived.Index
FROM tbVendor, Unit INNER JOIN PartsArchived ON Unit.Truck = PartsArchived.Truck
WHERE (((Unit.Truck)=[Enter Equipment or Stock]) AND ((PartsArchived.[Print Order])=Yes) AND ((PartsArchived.Technician)=[' Enter your first and last initial to print requisition ']) AND ((tbVendor.[tbVendor Name]) Like [Enter The First Few Characters of the Vendor: ] & "*"));
Hey..any help is greatly appreciated.
Thanks
JZ


Testkitt2
 
These are parameters to that query:

[Enter Equipment or Stock]
[' Enter your first and last initial to print requisition ']
[Enter The First Few Characters of the Vendor: ]

I believe those are the 3 parameters it is looking for. I don't know how you are using this SQL that you would generate the error, but you can feed the parameters to the query by assigning it to a querydef.

Code:
dim qd as DAO.QueryDef

set qd = CurrentDB.CreateQueryDef("",strsql)

qd("[Enter Equipment or Stock]") = sDynamicSolution
qd("[' Enter your first and last initial to print requisition ']") = "Static Solution"
qd("[Enter The First Few Characters of the Vendor: ]") = InputBox("Enter The First Few Characters of the Vendor:")

There are three different solutions with different appolicability and different functionality there for each of your parameters. You can then open the RecordSet of this query using the OpenRecordset method:

set rs = qd.OpenRecordset

And then continue from there.
 
I agree Rubbernilly but, since the parameter fields are the same as the last SQL, why aren't they working this time?

It seems that the forms GUIs are identical, and so, the utilization...

BTW the main part of this thread was...
CurrentDb.Execute "UPDATE PartsDescription SET [Print Order] = False"
Me!Req_Details.Form.Refresh

which should now be...
CurrentDb.Execute "UPDATE PartsArchived SET [Print Order] = False"
Me!*******.Form.Refresh

JZ, are your parameter text boxes named correctly?
Like rubbernilly said, it seems out of the 3 parameters, 2 are dynamic, one static, is that intentional?
 
Hello to all
thanks guys for your input.
I haven'had the chance to apply your theories.
but I will do that now and post ASAP
thanks
JZ

Testkitt2
 
Hello to all
Thanks for your comments

What I have here is a twin subform... if you want to call it
that. The first set of instructions behind the code that unchecks the checkboxes that are left checked off...works fine. but the other subform is an archive subform..for those requistions that are complete..but have the ability to be reprinted if that the case.. thus it has a checkbox that can be left checked off by one of 4 users that use this DB.
quick summary
To print the requisition forms works like this:
It asks for a truck/Unit number, then the persons initials, then a vendor that will be used to buy the item... it looks for the check box to be checked off ..otherwise..it does not print anything..just returns a msgbox.. The checkbox avoids the DB from printing everthing in the subform.

sorry to be long winded...

so now I have an active subform for current requisitions and
an archive subform for current that was archived because it was complete. The forms are visible = true...visible = false by a button for each.
Could it be that when using the archived subform... the active and current subform is opened in the background. And
yes the forms are alike with the exception of a few name changing. the button on the mainform is where i placed the original code to uncheck the checkboxes on the subform.
hope I didn't confuse anybody..
Main forms name is "Backlogform"

(1st main) subform name is "Req_Details"

(2nd archived) subform name is "Arch_Details"

Queries are:
1. PartsRequisition
2. ArchiveReqs
Thanks
JZ





Testkitt2
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top