R
Robert5833
Hi all;
The more I learn…the more I learn how much I have yet to learn…
Vista Business, Access 2007; computer is fast with tons of RAM
I have a slight dilemma; I have a form that I use to filter records in one
table (call them requirements) based on their relationship to a unique item
in another table (an item’s model number).
This information (the form’s recordset) is then appended to another table as
a list of requirements used for tracking purposes.
From the table the requirements are taken from, I have a field that stores a
value for the quantity required to make up a complete assembly; nothing
special there.
My dilemma is that the appended recordset needs be a sum total of those
records which have a multiple greater than one (1). The table to which the
data (recordset) is appended allows duplicates, so that’s not a problem.
The problem is that I don’t know how to build a procedure or function that
will either pass the results into my INSERT INTO function, or to perhaps to
call such a function from within the INSERT INTO function.
Here’s my INSERT INTO procedure:
Public Function loadMe()
On Error GoTo Error_Handler
Dim dbs As DAO.Database
Set dbs = CurrentDb
CurrentDb.Execute "INSERT INTO tblTracked([fldTrackedID], " _
& "[fldTrackedMake], [fldTrackedModel], [fldTrackedPN]) " & _
"SELECT fldTrackedID, fldTrackedMake, fldTrackedModel, " & _
"fldTrackedPN " & _
"FROM tblTrackReqd " & _
"WHERE tblTrackReqd.fldTrackedID = " &
[Forms]![frmBuildTracked]![cboSelTrackedModel], dbFailOnError
Exit_Procedure:
On Error Resume Next
Set dbs = Nothing
Exit Function
Error_Handler:
DisplayUnexpectedError Err.Number, Err.Description
Resume Exit_Procedure
Resume
End Sub
The above procedure is compiled, and doesn’t throw any errors (and it works
too!).
Meanwhile I’ve created a Function to return the value (quantity) required
for each complete assembly, but I think it’s only able to return one
instance, rather than a looped (?) collection of the result for the entire
recordset. (I’ve received some good tutoring on Functions and Subs from folks
here in these Discussion Groups, but I’m nowhere close to being able to
build/use them effectively.)
The alternative I suppose is to list each item in the requirements table by
the multiple required for each assembly. But that’s kind of cheesy, and I
know the best way to do it for the long-term is through automation.
I just wish I knew how… <frown>
If anyone has a good idea or two on how I might be able to do this, or if
what I’ve described that I think I want to do sounds a bit like pushing rope
up a hill <smile>; well I’d appreciate being educated on that too.
Thank you in advance for any help and advice.
Best regards,
RL
The more I learn…the more I learn how much I have yet to learn…
Vista Business, Access 2007; computer is fast with tons of RAM
I have a slight dilemma; I have a form that I use to filter records in one
table (call them requirements) based on their relationship to a unique item
in another table (an item’s model number).
This information (the form’s recordset) is then appended to another table as
a list of requirements used for tracking purposes.
From the table the requirements are taken from, I have a field that stores a
value for the quantity required to make up a complete assembly; nothing
special there.
My dilemma is that the appended recordset needs be a sum total of those
records which have a multiple greater than one (1). The table to which the
data (recordset) is appended allows duplicates, so that’s not a problem.
The problem is that I don’t know how to build a procedure or function that
will either pass the results into my INSERT INTO function, or to perhaps to
call such a function from within the INSERT INTO function.
Here’s my INSERT INTO procedure:
Public Function loadMe()
On Error GoTo Error_Handler
Dim dbs As DAO.Database
Set dbs = CurrentDb
CurrentDb.Execute "INSERT INTO tblTracked([fldTrackedID], " _
& "[fldTrackedMake], [fldTrackedModel], [fldTrackedPN]) " & _
"SELECT fldTrackedID, fldTrackedMake, fldTrackedModel, " & _
"fldTrackedPN " & _
"FROM tblTrackReqd " & _
"WHERE tblTrackReqd.fldTrackedID = " &
[Forms]![frmBuildTracked]![cboSelTrackedModel], dbFailOnError
Exit_Procedure:
On Error Resume Next
Set dbs = Nothing
Exit Function
Error_Handler:
DisplayUnexpectedError Err.Number, Err.Description
Resume Exit_Procedure
Resume
End Sub
The above procedure is compiled, and doesn’t throw any errors (and it works
too!).
Meanwhile I’ve created a Function to return the value (quantity) required
for each complete assembly, but I think it’s only able to return one
instance, rather than a looped (?) collection of the result for the entire
recordset. (I’ve received some good tutoring on Functions and Subs from folks
here in these Discussion Groups, but I’m nowhere close to being able to
build/use them effectively.)
The alternative I suppose is to list each item in the requirements table by
the multiple required for each assembly. But that’s kind of cheesy, and I
know the best way to do it for the long-term is through automation.
I just wish I knew how… <frown>
If anyone has a good idea or two on how I might be able to do this, or if
what I’ve described that I think I want to do sounds a bit like pushing rope
up a hill <smile>; well I’d appreciate being educated on that too.
Thank you in advance for any help and advice.
Best regards,
RL