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
17 4786
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. - Private Sub btnSelectAll_Click()
-
On Error GoTo Error_Routine
-
-
Dim strSQL As String
-
-
strSQL = "Update [YourTable] SET [YourTable].[fldCkBoxFlag] = True"
-
strSQL = strSQL & " WHERE [YourTable].[fldCkBoxFlag] = False" & ";"
-
-
CurrentDb.Execute strSQL, dbFailOnError
-
Me.YourSub2.Refresh
-
-
Exit_Continue:
-
Exit Sub
-
Error_Routine:
-
MsgBox "Error# " & Err.Number & " " & Err.Description
-
Resume Exit_Continue
-
End Sub
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. - Private Sub btnSelectAll_Click()
-
On Error GoTo Error_Routine
-
-
Dim strSQL As String
-
-
strSQL = "Update [YourTable] SET [YourTable].[fldCkBoxFlag] = True"
-
strSQL = strSQL & " WHERE [YourTable].[fldCkBoxFlag] = False" & ";"
-
-
CurrentDb.Execute strSQL, dbFailOnError
-
Me.YourSub2.Refresh
-
-
Exit_Continue:
-
Exit Sub
-
Error_Routine:
-
MsgBox "Error# " & Err.Number & " " & Err.Description
-
Resume Exit_Continue
-
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
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.
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
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
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
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
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
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
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
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
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]
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
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.
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
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
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: - DoCmd.SetWarnings False
-
DoCmd.OpenQuery ("qrySetInvoicedTrueByOrderID")
-
DoCmd.SetWarnings True
-
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
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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...
|
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...
|
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...
|
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.
...
| |
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...
|
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...
|
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...
|
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...
|
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,...
|
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...
| |
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,...
|
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,...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 ...
| |
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...
| |