Any help with the following problem is gratefully received.
I have a combo box on a parent form that causes updates to a commission field in a subform. It is a continuous subform hence the need to scroll through each record in its recordset and apply the update as necessary.
The problem is that the changes to this field do no appear until the second time I update the combo box. .
E.g.
Commission field starts as 0.
Enter a value into the combobox (say 1) and check the commission field shows the corresponding new value (should be 40 say)
Still shows zero.
Change the combo box value to something else (say 2) check the commission field shows corresponding new value (should be 80 say)
Is now showing the value corresponing to 1 I.e. 40?!
I suspect I need to commit these changes somehow, I thought recordset.update would do this, but I guess not
Please help as I've been stuck on this for hours now.
Regards
Stooo.
comboBox_AfterUpdate()
'column number will be used to select the correct handset
'commission from a select query, dependent on upgrade status
Dim columnNumber As Integer
If Me!Upgrade Then
Select Case Me![Upgrade Banding].Value
Case "L"
columnNumber = 1
Case "M"
columnNumber = 2
Case "H"
columnNumber = 3
Case Else
columnNumber = 0
End Select
Else
columnNumber = 0
End If
'column number is adjusted for the length of the contract
columnNumber = columnNumber * Me!Term.Value
'define query and recordsets for handset commission and
'recordset for handset form where data will be entered
Dim wksThis As DAO.Workspace
Dim qryHSCommission As DAO.QueryDef
Dim rstHSCommission As DAO.Recordset
Dim rstHandset As DAO.Recordset
Dim idxRecord As Integer
Set wksThis = DBEngine(0)
Set qryHSCommission = CurrentDb.QueryDefs("qryHandsetcommissions")
Set rstHandset = Me!frmCustomerHandsets.Form.Recordset
'if recordset contains records then
If rstHandset.RecordCount <> 0 Then
'move to the first record on the handset form
rstHandset.MoveFirst
Do While Not rstHandset.EOF
qryHSCommission.Parameters("inputParam0Manufacturer") = rstHandset("Manufacturer")
qryHSCommission.Parameters("inputParam1Handset") = rstHandset("Handset")
qryHSCommission.Parameters("inputParam2Network") = Me!Network.Value
Set rstHSCommission = qryHSCommission.OpenRecordset
rstHSCommission.MoveFirst
rstHandset.Edit
rstHandset!Commission.Value = rstHSCommission(columnNumber).Value
rstHandset.Update
rstHSCommission.Close
rstHandset.MoveNext
Loop
End If
Set rstHSCommission = Nothing
Set qryHSCommission = Nothing
Set rstHandset = Nothing
I have a combo box on a parent form that causes updates to a commission field in a subform. It is a continuous subform hence the need to scroll through each record in its recordset and apply the update as necessary.
The problem is that the changes to this field do no appear until the second time I update the combo box. .
E.g.
Commission field starts as 0.
Enter a value into the combobox (say 1) and check the commission field shows the corresponding new value (should be 40 say)
Still shows zero.
Change the combo box value to something else (say 2) check the commission field shows corresponding new value (should be 80 say)
Is now showing the value corresponing to 1 I.e. 40?!
I suspect I need to commit these changes somehow, I thought recordset.update would do this, but I guess not
Please help as I've been stuck on this for hours now.
Regards
Stooo.
comboBox_AfterUpdate()
'column number will be used to select the correct handset
'commission from a select query, dependent on upgrade status
Dim columnNumber As Integer
If Me!Upgrade Then
Select Case Me![Upgrade Banding].Value
Case "L"
columnNumber = 1
Case "M"
columnNumber = 2
Case "H"
columnNumber = 3
Case Else
columnNumber = 0
End Select
Else
columnNumber = 0
End If
'column number is adjusted for the length of the contract
columnNumber = columnNumber * Me!Term.Value
'define query and recordsets for handset commission and
'recordset for handset form where data will be entered
Dim wksThis As DAO.Workspace
Dim qryHSCommission As DAO.QueryDef
Dim rstHSCommission As DAO.Recordset
Dim rstHandset As DAO.Recordset
Dim idxRecord As Integer
Set wksThis = DBEngine(0)
Set qryHSCommission = CurrentDb.QueryDefs("qryHandsetcommissions")
Set rstHandset = Me!frmCustomerHandsets.Form.Recordset
'if recordset contains records then
If rstHandset.RecordCount <> 0 Then
'move to the first record on the handset form
rstHandset.MoveFirst
Do While Not rstHandset.EOF
qryHSCommission.Parameters("inputParam0Manufacturer") = rstHandset("Manufacturer")
qryHSCommission.Parameters("inputParam1Handset") = rstHandset("Handset")
qryHSCommission.Parameters("inputParam2Network") = Me!Network.Value
Set rstHSCommission = qryHSCommission.OpenRecordset
rstHSCommission.MoveFirst
rstHandset.Edit
rstHandset!Commission.Value = rstHSCommission(columnNumber).Value
rstHandset.Update
rstHSCommission.Close
rstHandset.MoveNext
Loop
End If
Set rstHSCommission = Nothing
Set qryHSCommission = Nothing
Set rstHandset = Nothing