rsbutterfly16
Registered User.
- Local time
- Today, 01:05
- Joined
- Jun 5, 2006
- Messages
- 77
hi guys i was wondering if you can help me please, in my main form i have a text box which the user enter an item number , and a combo box with the main contracts., then a continuous subform which has a combo box with the subcontracts that belong to that main contracts, in the subform i also have a txtPriceA, and txtPriceB. my problem is that with the code i have the priceA and priceB get added in different rows and all the other fields get added correctly but with the columns priceA and priceB empty.
this is what i tried
Private Sub Command94_Click()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim varItem As Variant
Dim strSQL As String
Set rst = CurrentDb.OpenRecordset("tblMain")
For varItem = 0 To Me!frmAddSubform.Form!cmbSubContracts.ListCount - 1 'combo box from subform
rst.AddNew 'add new row for each subContract in combo box
rst!SubContract_ID = Me!frmAddSubform.Form!cmbSubContracts.Column(0, varItem)
rst!MainContractID= me.txtMainContract.value
rst!ItemNumber = Me.txtItem.Value
rst!PriceA = Me!frmAddSubform.Form!txtPriceA.Value (this is supposed to be added in the columm PriceA in the same row as the 1st row added from rst!subContract_ID. )
rst!Priceb = Me!frmAddSubform.Form!txtPriceB.Value (this is supposed to be added in the columm PriceB in the same row as the 2nd row added from rst!subContract_ID. )
rst.Update
Next varItem
rst.Close
But I get this:
ID (autonumber) Item# Main Contract Subcontract PriceA PriceB
1 123 12345 12345-1
2 123 12345 12345-2
3 $15.00 $ 15.01
4 $15.50 $ 16.01
I should only have two rows added instead of four....like this
ID (autonumber) Item# Main Contract Subcontract PriceA PriceB
1 123 12345 12345-1 $15.00 $ 15.01
2 123 12345 12345-2 $15.50 $ 16.01
also, i have my reasons why i have repeating rows.
this is what i tried
Private Sub Command94_Click()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim varItem As Variant
Dim strSQL As String
Set rst = CurrentDb.OpenRecordset("tblMain")
For varItem = 0 To Me!frmAddSubform.Form!cmbSubContracts.ListCount - 1 'combo box from subform
rst.AddNew 'add new row for each subContract in combo box
rst!SubContract_ID = Me!frmAddSubform.Form!cmbSubContracts.Column(0, varItem)
rst!MainContractID= me.txtMainContract.value
rst!ItemNumber = Me.txtItem.Value
rst!PriceA = Me!frmAddSubform.Form!txtPriceA.Value (this is supposed to be added in the columm PriceA in the same row as the 1st row added from rst!subContract_ID. )
rst!Priceb = Me!frmAddSubform.Form!txtPriceB.Value (this is supposed to be added in the columm PriceB in the same row as the 2nd row added from rst!subContract_ID. )
rst.Update
Next varItem
rst.Close
But I get this:
ID (autonumber) Item# Main Contract Subcontract PriceA PriceB
1 123 12345 12345-1
2 123 12345 12345-2
3 $15.00 $ 15.01
4 $15.50 $ 16.01
I should only have two rows added instead of four....like this
ID (autonumber) Item# Main Contract Subcontract PriceA PriceB
1 123 12345 12345-1 $15.00 $ 15.01
2 123 12345 12345-2 $15.50 $ 16.01
also, i have my reasons why i have repeating rows.