Hi Jerry,
That does simplify it. I know we ended up essentially where you
started. The questions and answers were valuable in that they helped me
understand the situation so that I answer the question correctly.
Create an After Update event for your form. In it add this:
Dim lngRecordsUpdated As Long
CurrentProject.Connection.Execute _
"update YourTableName " & _
"set OpeningBalance = " & txtEndingBalance & " " & _
"where EmployeeID = " & txtEmployeeID & " and " & _
"[Date] = #" & DateAdd("m", 1, txtDate) & "#", _
lngRecordsUpdated, adCmdText
If lngRecordsUpdated = 0 Then
MsgBox "No next record found to update."
End If
Where YourTableName is, well, your table's name and txtEndingBalance,
txtEmployeeID and txtDate are the names of the controls on your form. You
may need to do a Me.Refresh or Me.Requery after you do the update to the
table in order for it to show in the form.
A note of caution. Usage of the word Date as a column or other object
name is not a good idea as it is a reserved word. As such sometimes you can
get unexpected results. Better to use a more descriptive name such as
Start_Date or whatever is appropriate. Do a search in Access's online help
for "reserved words" for a list of the reserved words.
Hope this helps,
Clifford Bass
JWCrosby said:
Actually, it may be simpler than what you described. Picture a form with 12
rows showing, one for each month of the year, with several columns of various
calculations.
When I punch in some numbers it updates the "EndingBalance" using the
formula of [GrossPotential] minus [GrossAvailable].
If, say, I'm working in the January line, I want the updated EndingBalance
for January to become the "BeginningBalance" for February (BeginningBalance
is another column). It's just to save me from having to manually enter the
beginning balance each month since it's always the same as the ending balance
of the previous month. (This form is only used once a month.)
No changes need to be made in any previous months, just the one "next" month.
Need any more information? I've been struggling with this for some time
now. Thanks for any help you may have to offer.
Jerry
:
Hi Jerry,
Sorry for the delay--for some reason I did not get notified of your
response.
I presume then that if you make a change in any one month, then you
will want to update the opening and ending balances of any months between the
changed month and the months up through the first month in the future. Is
that accurate? What are the calculations you do to get the ending balance
for any one month? Those will need to be incorporated into the process.
Clifford Bass
:
Actually, Clifford, a record for each month is already created. It's such a
small database I could do that without worry of bloat. So, all 12 months are
visible at one time on the form. I want it so that if I make a change in
January's ending balance it will update the beginning balance in the February
record.
The December record of the previous year exists, too, so January's beginning
balance would have already been set.
Each record has a date field, which is set to the first day of the month
(e.g., 1/1/2009, 2/1/2009, 3/1/2009, etc.) and anEmployeeID key field.
That help any?
Jerry