Microsoft
Software
Hardware
Network
Question : Continuous subform using a DAO recordset/ Access 2000
Hello Experts,
I am stumped on this one, and I would appreciate your expert assistance. The problem with my current code is that, although the continuous subform in question runs without error, the underlying recordset code does not execute the looping porton of the code. It processes the first record in the loop, and then stops.
The subform with the problem, is the second of 2 embedded continuous subforms. The way that it is supposed to work is as follows: the main form has two cascading combo boxes, which combine to display (on the first subform) a filtered list of account codes associated to a selected line item (example- all general ledger codes for a line item code of 108 entitled Accounts Receivable). The second subform, is intended to enable the user to select from another combo box (one combo for each record displayed on the continuous subform) so that users can change the value of the bound column (line item code) to which each of the accounts are associated, with the change being automatically propagated to all accounts on the filtered list after the first selection is made. Although I can change each account one by one by making a selection in each combo box, I have not been successful in taking the first selection and propagating it to all of the account codes on the filtered list. Here is the pertinent code for the second subform.
The SQL code that was used to create the recordset for subform2:
--------------------------
----------
----------
----------
----------
----------
----------
----------
----------
------
strSQLSF2 = "SELECT " & "[tblChartOfAccts]" & "." & varAcctClass & "," & "[tblChartOfAccts]" & "." & varAcctCode2
strSQLSF2 = strSQLSF2 & "," & "[tblChartOfAccts]" & "." & varCafrLink2 & " From [tblChartOfAccts]"
strSQLSF2 = strSQLSF2 & " WHERE [tblChartOfAccts]" & "." & varAcctCode2 & " IN " & "(Select " & varAcctCode & " From TempQry)"
strSQLSF2 = strSQLSF2 & " ORDER BY " & varAcctCode2
--------------------------
----------
----------
----------
----------
----------
----------
----------
----------
---------
Option Compare Database
Option Explicit
Dim iOldBoundColumnValue As Integer
Dim iNewBoundColumnValue As Integer
Dim sNewBoundColumnDescr As String
Private Sub cboAcctClass_Change()
On Error GoTo Error_Routine
Dim dBs As DAO.Database
Dim rst As DAO.Recordset
Dim iRecCount As Integer 'record count
Dim intReturn As Integer 'return from message box
Me.Parent!cboInquiryFinder
.Requery
Me.Parent!frmChartUpdate_D
etailCtl.F
orm![txtAc
ctTitle].R
equery
'open recordset clone to handle combo box processing
Set dBs = CurrentDb()
Set rst = Forms("frmChartUpdate_Main
").Control
s("frmChar
tUpdate_De
tailCtl2")
.Form.Reco
rdsetClone
'get record count
iRecCount = rst.RecordCount
If Not (rst.BOF Or rst.EOF) Then
With rst
rst.MoveFirst
'capture selection from combo box
Me.cboAcctClass.SetFocus
iNewBoundColumnValue = Me!cboAcctClass.Value
sNewBoundColumnDescr = Me!cboAcctClass.Column(1)
intReturn = MsgBox("You are about to change the report classification to " & sNewBoundColumnDescr & " for all " & iRecCount & " records.", vbOKCancel)
If intReturn = vbCancel Then
MsgBox "You must use the Chart of Accounts to make selective changes."
cboAcctClass.Undo
Resume Exit_Continue
Else
'rst.MoveNext
'change all rows to new value of cboSelectIdx
Do Until rst.EOF
rst.Edit
With cboAcctClass
'Retrieves the value of the bound column which may or may not be
'displayed in the list box
If iOldBoundColumnValue <> iNewBoundColumnValue Then
Me!cboAcctClass.Value = iNewBoundColumnValue
End If
End With
rst.Update
Me!cboAcctClass.Requery
' Forms("frmChartUpdate_Main
").Control
s("frmChar
tUpdate_De
tailCtl2")
.Form.Requ
ery
If iRecCount > 1 Then
rst.MoveNext
Else
Exit Do
End If
Loop
End If
End With
End If
rst.Close
Exit_Continue:
'clean up
Set rst = Nothing
iRecCount = 0
iOldBoundColumnValue = Empty
iNewBoundColumnValue = Empty
sNewBoundColumnDescr = Empty
intReturn = 0
Exit Sub
Error_Routine:
MsgBox "Error# " & Err.Number & " " & Err.Description
Resume Exit_Continue
End Sub
Private Sub cboAcctClass_Enter()
On Error GoTo Error_Routine
If Not IsNull(Me!cboAcctClass.Val
ue) Then
iOldBoundColumnValue = Me!cboAcctClass.Value
End If
Exit_Continue:
Exit Sub
Error_Routine:
MsgBox "Error# " & Err.Number & " " & Err.Description
Resume Exit_Continue
End Sub
Answer : Continuous subform using a DAO recordset/ Access 2000
I would expect to see it done this way
Do Until rst.EOF
rst.Edit
rst.fields("TheFieldYouAre
Updating")
.value = iNewBoundColumnValue
rst.Update
rst.movenext
loop
Seems you are looping through the recordset setting the same field each time using this method
Me!cboAcctClass.Value = iNewBoundColumnValue
Random Solutions
How to apply switch case in ajax?
Using Cisco IAD 2430 as Primary Router/Firewall?
how to find out howmany jobs are running in database
Physical Volume Library Robot not found
AJAX just doesn't work :( VS.2008, .NET 2.0, AJAX 1.0
No mapping between account names and security IDs was done. Event ID 1202
Dump file tree into excel.
Cannot access new share on Windows Home Server
Home network - Browser can not connect
Citrix Tools