Advertisement

12.06.2006 at 07:53AM PST, ID: 22084329
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.6

Continuous subform with checkboxes

Asked by puppydogbuddy in Microsoft Access Database

Tags: ,

Hello Experts,
This problem is driving me nuts and I would appreciate any help you can provide.  I created a form for my application that consists of a main form and 2 continuous subforms, each of which contains a subform control on the main form.  Everything works perfectly, except for the ticking of checkboxes on the second continuous subform, which will be discussed in detail below.  

The purpose of the form is to enable the user to do “bulk” changes to any of several report classifications defined in the Chart of Accounts. The form works like this: The user selects via combo boxes on the main form, a report that has the accounts with the line item classification that they want to change.  The first continuous subform returns a list of all the accounts and amounts from the report that has the line item selected.  The second continuous form repeats the list of accounts, but has checkboxes for the user to designate which accounts are to have their classification changed, and has a combo box with a selection list for the new classification.

Everything works fine until I try to tick or untick a checkbox.  I get an error message “Error 3061…..Too few parameters…2 expected. ……….on the line :

    Set qD = dBs.CreateQueryDef("TempQry2")

 This does not make sense because the querydef generates the query perfectly.
In fact, if I go to the query window and open the query (“TempQry2”), it shows that one checkbox has been ticked.  Help!!!

Here is my code:

Private Sub Ckbox_AfterUpdate()
On Error GoTo Error_Routine

If Me.Dirty Then
    Me.Dirty = False
End If

If strBtnFlag = "SelectAll" Then
    Dim strSQLSF3 As String

    strSQLSF3 = "Update [tblChartOfAccts] SET [tblChartOfAccts].[fldChartBlockUpdFlag]= True"
    strSQLSF3 = strSQLSF3 & " WHERE [tblChartOfAccts].[fldChartBlockUpdFlag] = False" & ";"

    CurrentDb.Execute strSQLSF3, dbFailOnError
    Me.Refresh
ElseIf strBtnFlag = "Deselect" Then
    Dim strSQLSF4 As String

    strSQLSF4 = "Update [tblChartOfAccts] SET [tblChartOfAccts].[fldChartBlockUpdFlag]= False"
    strSQLSF4 = strSQLSF4 & " WHERE [tblChartOfAccts].[fldChartBlockUpdFlag] = True" & ";"

    CurrentDb.Execute strSQLSF4, dbFailOnError
    Me.Refresh
Else                                        'If strBtnFlag = "ItemSelected" Then
    Dim qD As DAO.QueryDef
    Dim rst As DAO.Recordset
    Dim rst2 As DAO.Recordset
    Dim iRecCount As Integer             'record count
    Dim intReturn As Integer               'return from message box
    Dim ctrl As Control, bytCount As Byte  'count of checkboxes ticked
    Dim strFilter As String


    'open recordset to handle combo box processing
   
   
    Set dBs = CurrentDb()
    'erase querydefs if it exists
    DeleteTempQuery ("TempQry2")
   
    strSearch = "Select varAcctCode From TempQry"
    strReplace = CStr("Select " & varAcctCode & " From " & "TempQry")
     
    strSQLSF2 = Replace(CStr(strSQLSF2), CStr(strSearch), CStr(strReplace))
   
       
   
    Set qD = dBs.CreateQueryDef("TempQry2")
    qD.SQL = strSQLSF2
   
    'Create a new Recordset based on the stored QueryDef from the Query .
    Set rst = qD.OpenRecordset

    'filter recordset by checkboxes ticked
    rst.Filter = "Me!Ckbox = True"
    rst.Sort = varAcctCode2
   
    'open a new recordset to receive filtered result set
    Set rst2 = rst.OpenRecordset
    iRecCount = rst2.RecordCount
    bytCount = 0  'initialize counter for checkboxes ticked

    If Not (rst2.BOF Or rst2.EOF) Then
        With rst2
            rst2.MoveLast
            rst2.MoveFirst
            Do Until rst2.EOF
                If Me.Ckbox = -1 And iOldBoundColumnValue = iNewBoundColumnValue Then
                   ' On Error Resume Next
                    bytCount = bytCount + 1
                    MsgBox "You haven't selected the new classification from any combo box."
                    Exit Do
                End If
                If Me.Ckbox = -1 And iOldBoundColumnValue <> iNewBoundColumnValue Then
'MsgBox "Test#1 sub2 " & iOldBoundColumnValue
'MsgBox "Test#1 sub2 " & iNewBoundColumnValue
                'change all rows that have been checked to new value of the BoundColumn
                        rst2.Edit
                            With cboAcctClass
                                  'Retrieves the value of the variable containing bound column, which may be hidden (0 width) in the listbox
                                  rst2.Fields(CStr(varAcctClass)).Value = iNewBoundColumnValue
                            End With
                        rst2.Update
                        Me.Refresh
                        If iRecCount >= 1 Then
                            rst2.MoveNext
                            iRecCount = iRecCount - 1
                        Else
                            Exit Do
                        End If
                End If
           Loop
       End With
    End If
    rst.Close
    rst2.Close
End If
Exit_Continue:
    'clean up
    Set qD = Nothing
    Set rst = Nothing
    Set rst2 = Nothing
    Set strSQLSFz = Nothing
    strSQLSF5 = Empty
    iRecCount = 0
    iOldBoundColumnValue = 0
    iNewBoundColumnValue = 0
    sNewBoundColumnDescr = Empty
  ' intReturn = 0
    strBtnFlag = Empty
Error_Routine:
        MsgBox "Error# " & Err.Number & " " & Err.Description
        Resume Exit_Continue
End Sub
Start Free Trial
[+][-]12.06.2006 at 08:02AM PST, ID: 18085875

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Microsoft Access Database
Tags: subform, checkbox
Sign Up Now!
Solution Provided By: jefftwilley
Participating Experts: 1
Solution Grade: A
 
 
[+][-]12.06.2006 at 08:16AM PST, ID: 18086016

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.06.2006 at 09:07AM PST, ID: 18086497

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.06.2006 at 09:34AM PST, ID: 18086702

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.07.2006 at 08:19AM PST, ID: 18094314

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.07.2006 at 08:53AM PST, ID: 18094752

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.07.2006 at 02:28PM PST, ID: 18097727

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.11.2006 at 06:22AM PST, ID: 18114720

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-42