473,473 Members | 2,286 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How do I check all check box controls on a Continuous Form?

32 New Member
Hi group,

How do I check all check box controls on a Continuous Form?

I have a form (Main) with two SubForms (Sub1 and Sub2). Sub1 has a button that is supposed to check all the check boxes visible in the SourceObject of Sub2. The SourceObject of Sub2 is a Continous Form based on a query.

I need to be able to click the button and have all the check boxes become checked.

Right now, I can only get teh first one to check!

I'm trying to do this as efficiently as possible, so any help would be much appreciated!

Oliver
Jan 15 '08 #1
17 4786
puppydogbuddy
1,923 Recognized Expert Top Contributor
Hi group,

How do I check all check box controls on a Continuous Form?

I have a form (Main) with two SubForms (Sub1 and Sub2). Sub1 has a button that is supposed to check all the check boxes visible in the SourceObject of Sub2. The SourceObject of Sub2 is a Continous Form based on a query.

I need to be able to click the button and have all the check boxes become checked.

Right now, I can only get teh first one to check!

I'm trying to do this as efficiently as possible, so any help would be much appreciated!
Oliver
Hi Oliver,
If I recall correctly, your sub2 is a subform of sub1. Try this for your select all button. In order for you to do what you want on a continuous form, the checkbox field must be bound to a field in your table.

Expand|Select|Wrap|Line Numbers
  1. Private Sub btnSelectAll_Click()
  2. On Error GoTo Error_Routine
  3.  
  4.     Dim strSQL As String
  5.  
  6.     strSQL = "Update [YourTable] SET [YourTable].[fldCkBoxFlag] = True"
  7.     strSQL = strSQL & " WHERE [YourTable].[fldCkBoxFlag] = False" & ";"
  8.  
  9.     CurrentDb.Execute strSQL, dbFailOnError
  10.     Me.YourSub2.Refresh
  11.  
  12. Exit_Continue:
  13.         Exit Sub
  14. Error_Routine:
  15.         MsgBox "Error# " & Err.Number & " " & Err.Description
  16.         Resume Exit_Continue
  17. End Sub
Jan 15 '08 #2
olivero
32 New Member
Hi Oliver,
If I recall correctly, your sub2 is a subform of sub1. Try this for your select all button. In order for you to do what you want on a continuous form, the checkbox field must be bound to a field in your table.

Expand|Select|Wrap|Line Numbers
  1. Private Sub btnSelectAll_Click()
  2. On Error GoTo Error_Routine
  3.  
  4.     Dim strSQL As String
  5.  
  6.     strSQL = "Update [YourTable] SET [YourTable].[fldCkBoxFlag] = True"
  7.     strSQL = strSQL & " WHERE [YourTable].[fldCkBoxFlag] = False" & ";"
  8.  
  9.     CurrentDb.Execute strSQL, dbFailOnError
  10.     Me.YourSub2.Refresh
  11.  
  12. Exit_Continue:
  13.         Exit Sub
  14. Error_Routine:
  15.         MsgBox "Error# " & Err.Number & " " & Err.Description
  16.         Resume Exit_Continue
  17. End Sub
Hi Puppydogbuddy,

Actually in this case, Sub2 is at the same level as Sub1 (I'm working on a different form now). I'll give this a shot and send an update, but I won't likely get to this until tonight.

Is there a way to do this by interacting with the form, instead of the query? I like how clean your method is, but I'm just curious. If this works for me, it will be the exception in the DB so far, as all my other changes have been made by changing the values of forms and not by directly coded SQL statements.

Thanks for the help!

Oliver
Jan 15 '08 #3
puppydogbuddy
1,923 Recognized Expert Top Contributor
Hi Puppydogbuddy,

Actually in this case, Sub2 is at the same level as Sub1 (I'm working on a different form now). I'll give this a shot and send an update, but I won't likely get to this until tonight.

Is there a way to do this by interacting with the form, instead of the query? I like how clean your method is, but I'm just curious. If this works for me, it will be the exception in the DB so far, as all my other changes have been made by changing the values of forms and not by directly coded SQL statements.

Thanks for the help!

Oliver
Although I think the above approach is better and more efficient, you should be able to do it thru the form as long as the form is bound to your table and your button includes a refresh/requery command.
Jan 15 '08 #4
olivero
32 New Member
Although I think the above approach is better and more efficient, you should be able to do it thru the form as long as the form is bound to your table and your button includes a refresh/requery command.
Your first method is certainly better and more efficient!

I got back late tonight and haven't had a chance to try this out yet. I'll keep you posted.

Oliver
Jan 16 '08 #5
olivero
32 New Member
Your first method is certainly better and more efficient!

I got back late tonight and haven't had a chance to try this out yet. I'll keep you posted.

Oliver
I've been swamped this week and haven't had a chance to get back to this project! Sorry for the delay in replying to you. I hope to get back on this over the weekend.

Oliver
Jan 18 '08 #6
olivero
32 New Member
I've been swamped this week and haven't had a chance to get back to this project! Sorry for the delay in replying to you. I hope to get back on this over the weekend.

Oliver

Hey there,

Sorry for the delay getting back. I've tried the code, though I had to adapt it slightly because the button is on Sub1 of Main and the Continuous Form is on another Sub form of Main, at the same level as Sub1.

Main
-->Sub1
-->Sub2 = same level as Sub1

It seemd to work through the SQL statements, but I got errors on the next two lines.

I had to change one line to this:

Forms!Main!frmSubInvoices2.Refresh

But apparently, the Refresh property isn't available for a form?!! Is there another way to do this?

The "CurrentDb.Execute strSQL, dbFailOnError" line got this error:

"Runtime error 3061
Too few parametres, expected 1"

Any suggestions on how to work through this?

Thanks for waiting around!

Oliver
Jan 20 '08 #7
puppydogbuddy
1,923 Recognized Expert Top Contributor
Hey there,

Sorry for the delay getting back. I've tried the code, though I had to adapt it slightly because the button is on Sub1 of Main and the Continuous Form is on another Sub form of Main, at the same level as Sub1.

Main
-->Sub1
-->Sub2 = same level as Sub1

It seemd to work through the SQL statements, but I got errors on the next two lines.

I had to change one line to this:

Forms!Main!frmSubInvoices2.Refresh

But apparently, the Refresh property isn't available for a form?!! Is there another way to do this?

The "CurrentDb.Execute strSQL, dbFailOnError" line got this error:

"Runtime error 3061
Too few parametres, expected 1"

Any suggestions on how to work through this?

Thanks for waiting around!

Oliver
Oliver,
Refresh is available for a form...it is not available in your case because you have the wrong syntax.

In your case, if sub1 and sub2 are both subforms on the same level, then both are accessed through their subform control on the main form. Given that the "select all" button is on sub1 and the checkboxes are on sub2, then the button click syntax should be something like this (I am assuming that frmSubInvoices2 is the source object for Sub2, and not the subform control. However, even if it were the subform control, your syntax did not contain the reference to the Form property before the Refresh):

Forms!Main!YourSubformControlforSub2.Form.Refresh

Let me know what happened. Thanks.

PDB
Jan 21 '08 #8
olivero
32 New Member
Oliver,
Refresh is available for a form...it is not available in your case because you have the wrong syntax.

In your case, if sub1 and sub2 are both subforms on the same level, then both are accessed through their subform control on the main form. Given that the "select all" button is on sub1 and the checkboxes are on sub2, then the button click syntax should be something like this (I am assuming that frmSubInvoices2 is the source object for Sub2, and not the subform control. However, even if it were the subform control, your syntax did not contain the reference to the Form property before the Refresh):

Forms!Main!YourSubformControlforSub2.Form.Refresh

Let me know what happened. Thanks.

PDB

PDB,

There's a punctuation mark missing in your example, so I've tried these syntices (and a few other too, I think), but I'm getting errors (Object doesn't support this property or method):

Forms!Main!frmSubInvoices2!chkInvoiced!Form.Refres h
Forms!Main!frmSubInvoices2!chkInvoiced.Form.Refres h
Forms!Main!frmSubInvoices2.chkInvoiced!Form.Refres h
Forms!Main!frmSubInvoices2.chkInvoiced.Form!Refres h
Forms!Main!frmSubInvoices2.chkInvoiced.Refresh
Forms!Main!frmSubInvoices2.chkInvoiced!Refresh
Forms!Main!frmSubInvoices2!chkInvoiced!Refresh
Forms!Main!frmSubInvoices2!chkInvoiced.Refresh
Forms!Main!frmSubInvoices2.Refresh

Any suggestions?

Oliver
Jan 22 '08 #9
puppydogbuddy
1,923 Recognized Expert Top Contributor
PDB,

There's a punctuation mark missing in your example, so I've tried these syntices (and a few other too, I think), but I'm getting errors (Object doesn't support this property or method):

Forms!Main!frmSubInvoices2!chkInvoiced!Form.Refres h
Forms!Main!frmSubInvoices2!chkInvoiced.Form.Refres h
Forms!Main!frmSubInvoices2.chkInvoiced!Form.Refres h
Forms!Main!frmSubInvoices2.chkInvoiced.Form!Refres h
Forms!Main!frmSubInvoices2.chkInvoiced.Refresh
Forms!Main!frmSubInvoices2.chkInvoiced!Refresh
Forms!Main!frmSubInvoices2!chkInvoiced!Refresh
Forms!Main!frmSubInvoices2!chkInvoiced.Refresh
Forms!Main!frmSubInvoices2.Refresh

Any suggestions?

Oliver
If frmSubInvoices2 is the subform control on the main form, then try this exactly as shown:

Forms!Main!frmSubInvoices2.Form.Refresh
Jan 22 '08 #10
olivero
32 New Member
If frmSubInvoices2 is the subform control on the main form, then try this exactly as shown:

Forms!Main!frmSubInvoices2.Form.Refresh

ok, that line worked. It seems so simple when you do it...!

I still don't fully understand the purpose of each punctuation mark. Although I get it right about 80% of the time, it's more from guessing...

Now, I'm still getting the other error I had mentioned earlier with the following line:

CurrentDb.Execute strSQL, dbFailOnError

Error = Too few parametres. Expected 1

I'll review my code for errors and report back.

Thanks for your help.

Oliver
Jan 23 '08 #11
olivero
32 New Member
ok, that line worked. It seems so simple when you do it...!

I still don't fully understand the purpose of each punctuation mark. Although I get it right about 80% of the time, it's more from guessing...

Now, I'm still getting the other error I had mentioned earlier with the following line:

CurrentDb.Execute strSQL, dbFailOnError

Error = Too few parametres. Expected 1

I'll review my code for errors and report back.

Thanks for your help.

Oliver
This mght help:

The error apparently happens if you WHERE points to a control on a form. This isn't what we are doing (though being able to do it would solve the issue).

Apparently, this error can also happen if the query requires a parameter. It doesn, because I'm using this as he criteria on the OrderID field in the query:

DLookUp("[OrderID]","[Order Details]","[OrderID] = " & [Forms]![Main]![frmSubInvoices1].[Form]![cmbOrderIDInvoices])

Though it might be best to keep our code strictly referencing the query and not the form, the form is already showing what I want to see because of this Criteria in the query.

If we can turn the above DLookUp into SQL, we can use PARAMETERS in strSQL. Are you able to convert this for me?

Thanks,
Oliver
Jan 23 '08 #12
puppydogbuddy
1,923 Recognized Expert Top Contributor
This mght help:

The error apparently happens if you WHERE points to a control on a form. This isn't what we are doing (though being able to do it would solve the issue).

Apparently, this error can also happen if the query requires a parameter. It doesn, because I'm using this as he criteria on the OrderID field in the query:

DLookUp("[OrderID]","[Order Details]","[OrderID] = " & [Forms]![Main]![frmSubInvoices1].[Form]![cmbOrderIDInvoices])

Though it might be best to keep our code strictly referencing the query and not the form, the form is already showing what I want to see because of this Criteria in the query.

If we can turn the above DLookUp into SQL, we can use PARAMETERS in strSQL. Are you able to convert this for me?

Thanks,
Oliver
You will also get the parameter message when you use an object reference that Access does not recognize.....usually the result of a mispelled or incorrect reference. In the DLookup, you are supplying the parameter via the form. I have a strong feeling that your reference to frmSubInvoices1 is incorrect....it should be frmSubInvoices2...am I correct?

If that is not it.... is "[Order Details]" a query?....if it is a query, Access generally requires parameters used to be declared. you can do the declaration by placing the query in design view and selecting query>parameters from the command menu. copy and paste your form parameter in the dialog box as shown

[Forms]![Main]![frmSubInvoices1].[Form]![cmbOrderIDInvoices]
Jan 23 '08 #13
olivero
32 New Member
You will also get the parameter message when you use an object reference that Access does not recognize.....usually the result of a mispelled or incorrect reference. In the DLookup, you are supplying the parameter via the form. I have a strong feeling that your reference to frmSubInvoices1 is incorrect....it should be frmSubInvoices2...am I correct?

If that is not it.... is "[Order Details]" a query?....if it is a query, Access generally requires parameters used to be declared. you can do the declaration by placing the query in design view and selecting query>parameters from the command menu. copy and paste your form parameter in the dialog box as shown

[Forms]![Main]![frmSubInvoices1].[Form]![cmbOrderIDInvoices]
the reference is correct. [Order Details] is a table. The control on frmSubInvoices1 is a combo box that uses a query to present the user with a list of orders that have not been invoiced yet - this query include the Order ID. The DLookUp grabs the OrderID from the record that the user chose and uses it as the criteria for the qryOrderDetailsByOrderID used in strSQL. It then pulls up all OrderDetails that are associated with the Order ID and presents them as a Continous Form in Sub2.

The queries work perfectly. I'm just having a hard time checking all the boxes for the Order Details that show up in the continuous form.

Oliver
Jan 23 '08 #14
puppydogbuddy
1,923 Recognized Expert Top Contributor
the reference is correct. [Order Details] is a table. The control on frmSubInvoices1 is a combo box that uses a query to present the user with a list of orders that have not been invoiced yet - this query include the Order ID. The DLookUp grabs the OrderID from the record that the user chose and uses it as the criteria for the qryOrderDetailsByOrderID used in strSQL. It then pulls up all OrderDetails that are associated with the Order ID and presents them as a Continous Form in Sub2.

The queries work perfectly. I'm just having a hard time checking all the boxes for the Order Details that show up in the continuous form.

Oliver
I have a similar application with checkboxes on a continuoua subform, and it works fine for me. One thing I do differently then you is that I have my buttons to select/deselect my checkboxes in the footer/header of my continuous form, For my Select All button, I just execute the sql and then do a Me.Refresh. It works much better this way because the buttons for the checkbox are in the same proximate subform as the checkboxes themselves.
Jan 23 '08 #15
olivero
32 New Member
I have a similar application with checkboxes on a continuoua subform, and it works fine for me. One thing I do differently then you is that I have my buttons to select/deselect my checkboxes in the footer/header of my continuous form, For my Select All button, I just execute the sql and then do a Me.Refresh. It works much better this way because the buttons for the checkbox are in the same proximate subform as the checkboxes themselves.
Another busy day... i haven't had a chance to work on this today, and I won't tomorrow. I'll need to follow up with you on the weekend again.

Thanks for the help so far, I appreciate it!

Oliver
Jan 24 '08 #16
olivero
32 New Member
Another busy day... i haven't had a chance to work on this today, and I won't tomorrow. I'll need to follow up with you on the weekend again.

Thanks for the help so far, I appreciate it!

Oliver
PDB,

Sorry for the delay. again. I put in some self study time and during this (while reading up on a completely different topic), I got the bright idea of just creating an Update Query object and calling that from the button on Sub1... In it, I could use the same DLookup for the criteria, and because the form is open, this should work.

I created the Parameter Update Query and tested it manually, and it works. I just need to find some time to update the VBA code so the button will call it.

I'll let you know how this goes.

Oliver
Jan 30 '08 #17
olivero
32 New Member
PDB,

Sorry for the delay. again. I put in some self study time and during this (while reading up on a completely different topic), I got the bright idea of just creating an Update Query object and calling that from the button on Sub1... In it, I could use the same DLookup for the criteria, and because the form is open, this should work.

I created the Parameter Update Query and tested it manually, and it works. I just need to find some time to update the VBA code so the button will call it.

I'll let you know how this goes.

Oliver
So that worked!

This is what I used on the event of the button:

Expand|Select|Wrap|Line Numbers
  1.     DoCmd.SetWarnings False
  2.     DoCmd.OpenQuery ("qrySetInvoicedTrueByOrderID")
  3.     DoCmd.SetWarnings True
  4.     Forms!Main!frmSubInvoices2.Form.Refresh
qrySetInvoicedTrueByOrderID is a simple Update query with the Order ID field and the Invoiced field. The Order ID field uses the DLookup aggregate domain function I pasted above somewhere as the criteria.

I think it's funny that I didn't think of doing it this way before, but...

I still like your original suggestion though. As a phase 2, I plan to rebuild this DB using only strict SQL and VBA. I'll likely use it then.

Thanks again for all the help. I do apprecaite it.

Oliver
Jan 31 '08 #18

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Joseph J. Egan | last post by:
I am extending an existing Access/VBA app and need to update a subform displayed in continuous view within a containing form. The existing form and subform have worked fine to date with the...
5
by: jdph40 | last post by:
Is there any way to do this on a form in Access 97? If the value of a combo box is .5, I want two check boxes to be visible (labels are a.m and p.m.). If the value of the combo box is 1, I want...
4
by: DBQueen | last post by:
I have a subform which is in Continuous Forms view. I have added a button to the bottom of the page to move to the next record using the button wizard (result: DoCmd.GoToRecord , , acNext). I...
0
by: Karl Roes | last post by:
I'm still having trouble posting follow-ups. :-( "Unable to retrieve message 7cc66112.0501041919.3a6628b4@posting.google.com" Now Turtle wrote "You'll need an extra field in the table...
4
by: Kathy | last post by:
What is the standard technique for handling the fields in the following scenario on a continuous form? Multiple Divisions. Each Division has multiple Buildings. Each Building has a Supervisor. ...
2
by: Lyn | last post by:
Hi, I am opening a form in Continuous mode to list the records from a recordset created in the calling form. The recordset object is declared as Public and is set into the new form's Recordset...
3
by: google | last post by:
I'm developing an application for use within my company in Access 2003. I'm new to '03, the application I did for my former employer was in '97. The two applications have similar functionality...
1
by: John T Ingato | last post by:
With excel VBA, I can do : Dim ctrGo as commandbutton Set ctrGo = me.controls.add("Go") which would create a button on the form. Can I do with with Access? When I try it, first of all the...
3
by: jsurkin | last post by:
I have a form that lists a single work request, with an attached continuous subform that lists specific items that are part of the request. Each item in the subform has a check box to indicate when...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.