PotatoDave
IS-IT--Management
I am trying to add a form where a data sheet is used to add rows to a table. I want the full data in the table to be made up a combination of the combo boxes on the main form, and then also from the datasheet. The situation is for entering orders into the datasheet, the depot, date, order type and time (wave - AM or PM) will be the same for each item (and should come from the combo boxes), but i want a new record for each product with quantity and the same data in the first few columns. The catch is I want the datasheet to have 2 columns, one with product code and the other for qty, and i want the datasheet to have a full list of active product codes (from a query), so that they just enter the qty required. I have tried the following to update the subform:
Private Sub Form_AfterInsert()
Dim prodq As DAO.Recordset
Dim db As Database
Dim LSQL As String
Set db = CurrentDb()
Set prodq = db.OpenRecordset("ActiveProd", dbOpenDynaset)
If prodq.RecordCount > 0 Then
prodq.MoveFirst
Do Until prodq.EOF
LSQL = "insert into data (commodity, Date, Wave, OType, Depot)"
LSQL = LSQL & " values ("
LSQL = LSQL & "'" & prodq.Fields("Code").Value & "', " & Date & "', " & Wave & "', " & OType & "', " & Depot & ")"
'Perform SQL
db.Execute LSQL
prodq.MoveNext
End If
Data_subform.Requery
End Sub
This is a bit of a mess from trying stuff from several different websites, I get no error, but the subform doesn't update and no data is added to the data table.
Private Sub Form_AfterInsert()
Dim prodq As DAO.Recordset
Dim db As Database
Dim LSQL As String
Set db = CurrentDb()
Set prodq = db.OpenRecordset("ActiveProd", dbOpenDynaset)
If prodq.RecordCount > 0 Then
prodq.MoveFirst
Do Until prodq.EOF
LSQL = "insert into data (commodity, Date, Wave, OType, Depot)"
LSQL = LSQL & " values ("
LSQL = LSQL & "'" & prodq.Fields("Code").Value & "', " & Date & "', " & Wave & "', " & OType & "', " & Depot & ")"
'Perform SQL
db.Execute LSQL
prodq.MoveNext
End If
Data_subform.Requery
End Sub
This is a bit of a mess from trying stuff from several different websites, I get no error, but the subform doesn't update and no data is added to the data table.