J
jb33
So thanks to some help from a couple of you I'm this far.
I have a jobs summary form/subform. Status records are
children of the jobs records. And there are roughly 20
phases to each job for which status is tracked. So I want
to press a button and automatically create 20 status
records in the subform - each a different phase from the
phases table.
'****************************
Dim dbs As DAO.Database
Dim qdf As QueryDef
'will contain phase records
Dim strSQl As String
Dim status As DAO.Recordset
'records to be added
Dim job_id As Long
'need to pass job_id from my form
Dim ws As Workspace
'thought this might be required to access form items
Set ws = DBEngine.Workspaces(0)
Set job_id = Forms!Job Summary!job_id
Set strSQL="SELECT * FROM phases;"
Set dbs = CurrentDb()
Set status = dbsSP.OpenRecordset("status", dbOpenDynaset)
Set qdf = dbs.CreateQueryDef("phases", strSQL)
'Now i think I have my Parent Record ID (job_id),
'control for adding records to the status table,
'and an array object containing all my phases (qdf).
'Or have i not actually run qdf yet?
'Need to step through qdf
counter=0
Do
status.AddNew
status![job_id] = job_id
status![phase_id] = qdf.[counter].[0]
'trying to assign the first element at 'counter'
'in the array.
Loop Until (qdf.[size]) = counter
'how do you return the array size?
Am I getting close?
tia, jb
I have a jobs summary form/subform. Status records are
children of the jobs records. And there are roughly 20
phases to each job for which status is tracked. So I want
to press a button and automatically create 20 status
records in the subform - each a different phase from the
phases table.
'****************************
Dim dbs As DAO.Database
Dim qdf As QueryDef
'will contain phase records
Dim strSQl As String
Dim status As DAO.Recordset
'records to be added
Dim job_id As Long
'need to pass job_id from my form
Dim ws As Workspace
'thought this might be required to access form items
Set ws = DBEngine.Workspaces(0)
Set job_id = Forms!Job Summary!job_id
Set strSQL="SELECT * FROM phases;"
Set dbs = CurrentDb()
Set status = dbsSP.OpenRecordset("status", dbOpenDynaset)
Set qdf = dbs.CreateQueryDef("phases", strSQL)
'Now i think I have my Parent Record ID (job_id),
'control for adding records to the status table,
'and an array object containing all my phases (qdf).
'Or have i not actually run qdf yet?
'Need to step through qdf
counter=0
Do
status.AddNew
status![job_id] = job_id
status![phase_id] = qdf.[counter].[0]
'trying to assign the first element at 'counter'
'in the array.
Loop Until (qdf.[size]) = counter
'how do you return the array size?
Am I getting close?
tia, jb