Update Fields from query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi there, using A02 on XP. Not a programmer, but learning more and more. Luv
the newsgroups!

I have a report that needs to have a few financial fields updated from an
imported file. My users export a text file from specialty software and then
open SAR.mdb. They locate the correct record [PlanNum] on a main form
(fSARMain) and then create a record on the subform linked to [PlanNum]
(fSAR). When they key in certain required data I have address and contact
info dump in from a couple tables based upon the Child/Master fields link.

Here is my quandry: The text file imported has no link fields. I have a
macro set up to clear the table and import the data so there's only one
record in the table at a time. I have created a query (qSARH01) that
assembles and calculates the data needed for my subform record.

Then I put a button on my form with the following that did compile but gives
me an error when I click on it. (Run-Time error 2465: application defined or
object defined error - highlights the 2 lines below with *)

Private Sub Import_SARH01_Click()
'Open a recordset on qSARH01
Dim rstR As DAO.Recordset
Set rstR = CurrentDb.OpenRecordset("qSARH01")

'Update the values in the subform
Forms("fSARMain").Forms.[fSAR].[PlanExpenses] = _ *debug highlights
rstR.Fields("PlanExpenses").Value
*debug highlights
Forms("fSARMain").Forms.[fSAR].[AdminExpenses] = _
rstR.Fields("AdminExpenses").Value
Forms("fSARMain").Forms.[fSAR].[BenefitsPaid] = _
rstR.Fields("BenefitsPaid").Value
rstR.close

End Sub

I need to get this to work before I multiply it for each user (so no one
overwrites each others text file data). Believe me, I know this can be done
much cleaner if I was a programmer but I am learning and cannot grasp the
complicated stuff. Is it because I have named the fields from the query to
the subform the same? Gotta be something simple. UGH!

If someone could have pity on a poor soul and provide some advice or answer
I would truly appreciate it.
 
Ya Hoo!!!! It works beautifully! Thank you VERY much for the prompt reply.
--
Bonnie


Klatuu said:
Bonnie,

I am not sure, but this might be an issue. I think your syntax is incorrect
here:
Forms("fSARMain").Forms.[fSAR].[PlanExpenses] = _ *debug highlights
rstR.Fields("PlanExpenses").Value

Try it this way:

Forms![fSARMain]![fSAR]![PlanExpenses] = _ *debug highlights
rstR.Fields("PlanExpenses").Value


Bonnie said:
Hi there, using A02 on XP. Not a programmer, but learning more and more. Luv
the newsgroups!

I have a report that needs to have a few financial fields updated from an
imported file. My users export a text file from specialty software and then
open SAR.mdb. They locate the correct record [PlanNum] on a main form
(fSARMain) and then create a record on the subform linked to [PlanNum]
(fSAR). When they key in certain required data I have address and contact
info dump in from a couple tables based upon the Child/Master fields link.

Here is my quandry: The text file imported has no link fields. I have a
macro set up to clear the table and import the data so there's only one
record in the table at a time. I have created a query (qSARH01) that
assembles and calculates the data needed for my subform record.

Then I put a button on my form with the following that did compile but gives
me an error when I click on it. (Run-Time error 2465: application defined or
object defined error - highlights the 2 lines below with *)

Private Sub Import_SARH01_Click()
'Open a recordset on qSARH01
Dim rstR As DAO.Recordset
Set rstR = CurrentDb.OpenRecordset("qSARH01")

'Update the values in the subform
Forms("fSARMain").Forms.[fSAR].[PlanExpenses] = _ *debug highlights
rstR.Fields("PlanExpenses").Value
*debug highlights
Forms("fSARMain").Forms.[fSAR].[AdminExpenses] = _
rstR.Fields("AdminExpenses").Value
Forms("fSARMain").Forms.[fSAR].[BenefitsPaid] = _
rstR.Fields("BenefitsPaid").Value
rstR.close

End Sub

I need to get this to work before I multiply it for each user (so no one
overwrites each others text file data). Believe me, I know this can be done
much cleaner if I was a programmer but I am learning and cannot grasp the
complicated stuff. Is it because I have named the fields from the query to
the subform the same? Gotta be something simple. UGH!

If someone could have pity on a poor soul and provide some advice or answer
I would truly appreciate it.
 
Bonnie,

I am not sure, but this might be an issue. I think your syntax is incorrect
here:
Forms("fSARMain").Forms.[fSAR].[PlanExpenses] = _ *debug highlights
rstR.Fields("PlanExpenses").Value

Try it this way:

Forms![fSARMain]![fSAR]![PlanExpenses] = _ *debug highlights
rstR.Fields("PlanExpenses").Value


Bonnie said:
Hi there, using A02 on XP. Not a programmer, but learning more and more. Luv
the newsgroups!

I have a report that needs to have a few financial fields updated from an
imported file. My users export a text file from specialty software and then
open SAR.mdb. They locate the correct record [PlanNum] on a main form
(fSARMain) and then create a record on the subform linked to [PlanNum]
(fSAR). When they key in certain required data I have address and contact
info dump in from a couple tables based upon the Child/Master fields link.

Here is my quandry: The text file imported has no link fields. I have a
macro set up to clear the table and import the data so there's only one
record in the table at a time. I have created a query (qSARH01) that
assembles and calculates the data needed for my subform record.

Then I put a button on my form with the following that did compile but gives
me an error when I click on it. (Run-Time error 2465: application defined or
object defined error - highlights the 2 lines below with *)

Private Sub Import_SARH01_Click()
'Open a recordset on qSARH01
Dim rstR As DAO.Recordset
Set rstR = CurrentDb.OpenRecordset("qSARH01")

'Update the values in the subform
Forms("fSARMain").Forms.[fSAR].[PlanExpenses] = _ *debug highlights
rstR.Fields("PlanExpenses").Value
*debug highlights
Forms("fSARMain").Forms.[fSAR].[AdminExpenses] = _
rstR.Fields("AdminExpenses").Value
Forms("fSARMain").Forms.[fSAR].[BenefitsPaid] = _
rstR.Fields("BenefitsPaid").Value
rstR.close

End Sub

I need to get this to work before I multiply it for each user (so no one
overwrites each others text file data). Believe me, I know this can be done
much cleaner if I was a programmer but I am learning and cannot grasp the
complicated stuff. Is it because I have named the fields from the query to
the subform the same? Gotta be something simple. UGH!

If someone could have pity on a poor soul and provide some advice or answer
I would truly appreciate it.
 
Back
Top