I have one table with 5 fields
Store, Year, Month, Acct#, Amount
Main form has
Store, Year and Month
Sub form has
Acct# and Amount
Everything displays fine. If the subform is blank, I added a button with the following code to add the records. There are suppose to be 5 records and I get 6. When I do Month 02, the first acct#1001 overwrites the month 01 and adds the 5 records.
Private Sub Command8_Click()
Dim strSQL As String
strSQL = "INSERT INTO Budget (Store, FiscaLYear, FiscalMonth, AccountNumber) " & _
"VALUES('" & Me.Store & "', '" & Me.FiscalYear & "','" & Me.FiscalMonth & "', '1001' ) ;"
CurrentDb.Execute strSQL
strSQL = "INSERT INTO Budget (Store, FiscaLYear, FiscalMonth, AccountNumber) " & _
"VALUES('" & Me.Store & "', '" & Me.FiscalYear & "','" & Me.FiscalMonth & "', '1002' ) ;"
CurrentDb.Execute strSQL
strSQL = "INSERT INTO Budget (Store, FiscaLYear, FiscalMonth, AccountNumber) " & _
"VALUES('" & Me.Store & "', '" & Me.FiscalYear & "','" & Me.FiscalMonth & "', '1003' ) ;"
CurrentDb.Execute strSQL
strSQL = "INSERT INTO Budget (Store, FiscaLYear, FiscalMonth, AccountNumber) " & _
"VALUES('" & Me.Store & "', '" & Me.FiscalYear & "','" & Me.FiscalMonth & "', '1004' ) ;"
CurrentDb.Execute strSQL
strSQL = "INSERT INTO Budget (Store, FiscaLYear, FiscalMonth, AccountNumber) " & _
"VALUES('" & Me.Store & "', '" & Me.FiscalYear & "','" & Me.FiscalMonth & "', '1005' ) ;"
CurrentDb.Execute strSQL
Requery
Store, Year, Month, Acct#, Amount
Main form has
Store, Year and Month
Sub form has
Acct# and Amount
Everything displays fine. If the subform is blank, I added a button with the following code to add the records. There are suppose to be 5 records and I get 6. When I do Month 02, the first acct#1001 overwrites the month 01 and adds the 5 records.
Private Sub Command8_Click()
Dim strSQL As String
strSQL = "INSERT INTO Budget (Store, FiscaLYear, FiscalMonth, AccountNumber) " & _
"VALUES('" & Me.Store & "', '" & Me.FiscalYear & "','" & Me.FiscalMonth & "', '1001' ) ;"
CurrentDb.Execute strSQL
strSQL = "INSERT INTO Budget (Store, FiscaLYear, FiscalMonth, AccountNumber) " & _
"VALUES('" & Me.Store & "', '" & Me.FiscalYear & "','" & Me.FiscalMonth & "', '1002' ) ;"
CurrentDb.Execute strSQL
strSQL = "INSERT INTO Budget (Store, FiscaLYear, FiscalMonth, AccountNumber) " & _
"VALUES('" & Me.Store & "', '" & Me.FiscalYear & "','" & Me.FiscalMonth & "', '1003' ) ;"
CurrentDb.Execute strSQL
strSQL = "INSERT INTO Budget (Store, FiscaLYear, FiscalMonth, AccountNumber) " & _
"VALUES('" & Me.Store & "', '" & Me.FiscalYear & "','" & Me.FiscalMonth & "', '1004' ) ;"
CurrentDb.Execute strSQL
strSQL = "INSERT INTO Budget (Store, FiscaLYear, FiscalMonth, AccountNumber) " & _
"VALUES('" & Me.Store & "', '" & Me.FiscalYear & "','" & Me.FiscalMonth & "', '1005' ) ;"
CurrentDb.Execute strSQL
Requery