Event Procedure Mystery

  • Thread starter Thread starter Bonnie A
  • Start date Start date
B

Bonnie A

Hi everyone! Using A02 on XP. I've had fits trying to bring data from sub
and subsub forms that are pulling data from various sources for billing
purposes (PartStmts, PartSearch, Amdmts, etc.) up to my bill record. I have
fields on the sub forms showing summaries of how many and how much. (I
usually keep them Visible.No but lately just show them to see if that helps.)
I just want folks to be able to click a button and the data (if any) is
copied over into the bill record. I used to have the code in a validation
macro but it didn't work there either. I have the code behind a button:

Private Sub UpdateSubs_Click()

Me.MailPartStmtCycleCount = Me.MailPartStmtCycleCopy
Me.MailPartStmtCount = Me.MailPartStmtCopy
Me.MailPartStmtFee = Me.MailPartStmtCount * 1.25

Me.AmdmtNum = Me.CountAmdmt
Me.AmdmtFee = Me.AmtDueAmdmt

If Me.AmdmtNum > 0 Then
Me.InclAmdmtFee = -1
End If

Me.PartSearchFeeCount = Me.PartSearchFeeCopy
Me.PartSearchFee = Me.PartSearchFeeCount * 10
End Sub

It worked at the time but now it doesn't. I've tried to switch the order
but can't make sense of this.

Also, here is how I'm pulling the data up from the subsub form for Amendments:

[AmtDueAmdmt] Control Source is:
=IIf(IsError([RPSAdminBillSubAmdmts].[Form]![AmdmtAmtDue]),0,[RPSAdminBillSubAmdmts].[Form]![AmdmtAmtDue])

So the data is sitting there in the field and I've checked the names
backwards and forwards. Also, if I separate the amendment pieces out to a
button of their own, they work. But for how long?

I'm not a programmer as I'm sure you know by now but would appreciate any
assistance or education you'd mind sharing.

I am stumped and my itsy bitsy Access reputation is going down the tube.
Help?!?!?

Thanks in advance for any assistance.
 
I'm not sure from your description which fields are in the main form and
which in the subform but the first part your code does not refer to your
subform at all.

That would look like

Me.MySubform.FORM.[MyControl]

Just for text purposes it will help to copy your current code in the button
onto a text doc, delete it and just put in

MsgBox Me.NameOfSubform.Form.NameOfsomecontrol

Also test each of the values which you want to pass.
MsgBox Me.MailPartStmtCycleCount


then you can test if the code is seeing what you think it is. If you didn't
click in the subform before clicking your button, it may be reading a
different line from what you think

Try putting test data into the control in your sub eg
Me.MySub.FORM.Mycontrol = 3



Make sure that you have the correct name for your subform. It may be
different from the one in the database window. Select your subform in the
Main Form's Design View. In Properties, look on the Other tab at Name

When you have updated the subform you then need to requery it so that your
new data becomes visible. Otherwise you may not see it until you re-open the
form depending on how your form is designed
Me.MySubform.Requery

Evi

Bonnie A said:
Hi everyone! Using A02 on XP. I've had fits trying to bring data from sub
and subsub forms that are pulling data from various sources for billing
purposes (PartStmts, PartSearch, Amdmts, etc.) up to my bill record. I have
fields on the sub forms showing summaries of how many and how much. (I
usually keep them Visible.No but lately just show them to see if that helps.)
I just want folks to be able to click a button and the data (if any) is
copied over into the bill record. I used to have the code in a validation
macro but it didn't work there either. I have the code behind a button:

Private Sub UpdateSubs_Click()

Me.MailPartStmtCycleCount = Me.MailPartStmtCycleCopy
Me.MailPartStmtCount = Me.MailPartStmtCopy
Me.MailPartStmtFee = Me.MailPartStmtCount * 1.25

Me.AmdmtNum = Me.CountAmdmt
Me.AmdmtFee = Me.AmtDueAmdmt

If Me.AmdmtNum > 0 Then
Me.InclAmdmtFee = -1
End If

Me.PartSearchFeeCount = Me.PartSearchFeeCopy
Me.PartSearchFee = Me.PartSearchFeeCount * 10
End Sub

It worked at the time but now it doesn't. I've tried to switch the order
but can't make sense of this.

Also, here is how I'm pulling the data up from the subsub form for Amendments:

[AmtDueAmdmt] Control Source is:
=IIf(IsError([RPSAdminBillSubAmdmts].[Form]![AmdmtAmtDue]),0,[RPSAdminBillSu
bAmdmts].[Form]![AmdmtAmtDue])

So the data is sitting there in the field and I've checked the names
backwards and forwards. Also, if I separate the amendment pieces out to a
button of their own, they work. But for how long?

I'm not a programmer as I'm sure you know by now but would appreciate any
assistance or education you'd mind sharing.

I am stumped and my itsy bitsy Access reputation is going down the tube.
Help?!?!?

Thanks in advance for any assistance.
 
Hi Evi,

Thank you very much for giving it a go. I think I may have been unclear on
a point:

I have sub and subsub forms but on my form I have unbound controls that are
"reading" the data. For example, one unbound control is named [AmtDueAmdmt].
[AmtDueAmdmt]'s Control Source is:
=IIf(IsError([RPSAdminBillSubAmdmts].[Form]![AmdmtAmtDue]),0,[RPSAdminBillSubAmdmts].[Form]![AmdmtAmtDue])

So, if there is no data, the unbound field reads zero and the code should
still work.

The bound field on my form is named [AmdmtFee]. When I click the button,
one of the lines of code to run is: Me.AmdmtFee = Me.AmtDueAmdmt

It should be a simple 'make this one equal that one' task.

I'm just not sure why I can't have 7 or 8 lines with that type of language
and some work sometimes and not others or just stop working when they used to.

Thank you again,
--
Bonnie W. Anderson
Cincinnati, OH


Evi said:
I'm not sure from your description which fields are in the main form and
which in the subform but the first part your code does not refer to your
subform at all.

That would look like

Me.MySubform.FORM.[MyControl]

Just for text purposes it will help to copy your current code in the button
onto a text doc, delete it and just put in

MsgBox Me.NameOfSubform.Form.NameOfsomecontrol

Also test each of the values which you want to pass.
MsgBox Me.MailPartStmtCycleCount


then you can test if the code is seeing what you think it is. If you didn't
click in the subform before clicking your button, it may be reading a
different line from what you think

Try putting test data into the control in your sub eg
Me.MySub.FORM.Mycontrol = 3



Make sure that you have the correct name for your subform. It may be
different from the one in the database window. Select your subform in the
Main Form's Design View. In Properties, look on the Other tab at Name

When you have updated the subform you then need to requery it so that your
new data becomes visible. Otherwise you may not see it until you re-open the
form depending on how your form is designed
Me.MySubform.Requery

Evi

Bonnie A said:
Hi everyone! Using A02 on XP. I've had fits trying to bring data from sub
and subsub forms that are pulling data from various sources for billing
purposes (PartStmts, PartSearch, Amdmts, etc.) up to my bill record. I have
fields on the sub forms showing summaries of how many and how much. (I
usually keep them Visible.No but lately just show them to see if that helps.)
I just want folks to be able to click a button and the data (if any) is
copied over into the bill record. I used to have the code in a validation
macro but it didn't work there either. I have the code behind a button:

Private Sub UpdateSubs_Click()

Me.MailPartStmtCycleCount = Me.MailPartStmtCycleCopy
Me.MailPartStmtCount = Me.MailPartStmtCopy
Me.MailPartStmtFee = Me.MailPartStmtCount * 1.25

Me.AmdmtNum = Me.CountAmdmt
Me.AmdmtFee = Me.AmtDueAmdmt

If Me.AmdmtNum > 0 Then
Me.InclAmdmtFee = -1
End If

Me.PartSearchFeeCount = Me.PartSearchFeeCopy
Me.PartSearchFee = Me.PartSearchFeeCount * 10
End Sub

It worked at the time but now it doesn't. I've tried to switch the order
but can't make sense of this.

Also, here is how I'm pulling the data up from the subsub form for Amendments:

[AmtDueAmdmt] Control Source is:
=IIf(IsError([RPSAdminBillSubAmdmts].[Form]![AmdmtAmtDue]),0,[RPSAdminBillSu
bAmdmts].[Form]![AmdmtAmtDue])

So the data is sitting there in the field and I've checked the names
backwards and forwards. Also, if I separate the amendment pieces out to a
button of their own, they work. But for how long?

I'm not a programmer as I'm sure you know by now but would appreciate any
assistance or education you'd mind sharing.

I am stumped and my itsy bitsy Access reputation is going down the tube.
Help?!?!?

Thanks in advance for any assistance.
 
So both AmtDueAmdmt and AmdmtFee are both main form? And your button is
also in your main form?

If this is the case, and it sometimes isn't working then it may mend if you
add to your code something to requery first your text box then AmtDueAmdmt.

Try this and see if it helps. If AmtDueAmdmt is in the subsubform, first
requery the first sub, then the subsub
'
Me.YourSubform.Requery
Me.AmtDueAmdmt.Requery
Me.AmdmtFee = Me.AmtDueAmdmt

Evi


Bonnie A said:
Hi Evi,

Thank you very much for giving it a go. I think I may have been unclear on
a point:

I have sub and subsub forms but on my form I have unbound controls that are
"reading" the data. For example, one unbound control is named [AmtDueAmdmt].
[AmtDueAmdmt]'s Control Source is:
=IIf(IsError([RPSAdminBillSubAmdmts].[Form]![AmdmtAmtDue]),0,[RPSAdminBillSu
bAmdmts].[Form]![AmdmtAmtDue])

So, if there is no data, the unbound field reads zero and the code should
still work.

The bound field on my form is named [AmdmtFee]. When I click the button,
one of the lines of code to run is: Me.AmdmtFee = Me.AmtDueAmdmt

It should be a simple 'make this one equal that one' task.

I'm just not sure why I can't have 7 or 8 lines with that type of language
and some work sometimes and not others or just stop working when they used to.

Thank you again,
--
Bonnie W. Anderson
Cincinnati, OH


Evi said:
I'm not sure from your description which fields are in the main form and
which in the subform but the first part your code does not refer to your
subform at all.

That would look like

Me.MySubform.FORM.[MyControl]

Just for text purposes it will help to copy your current code in the button
onto a text doc, delete it and just put in

MsgBox Me.NameOfSubform.Form.NameOfsomecontrol

Also test each of the values which you want to pass.
MsgBox Me.MailPartStmtCycleCount


then you can test if the code is seeing what you think it is. If you didn't
click in the subform before clicking your button, it may be reading a
different line from what you think

Try putting test data into the control in your sub eg
Me.MySub.FORM.Mycontrol = 3



Make sure that you have the correct name for your subform. It may be
different from the one in the database window. Select your subform in the
Main Form's Design View. In Properties, look on the Other tab at Name

When you have updated the subform you then need to requery it so that your
new data becomes visible. Otherwise you may not see it until you re-open the
form depending on how your form is designed
Me.MySubform.Requery

Evi

Bonnie A said:
Hi everyone! Using A02 on XP. I've had fits trying to bring data from sub
and subsub forms that are pulling data from various sources for billing
purposes (PartStmts, PartSearch, Amdmts, etc.) up to my bill record.
I
have
fields on the sub forms showing summaries of how many and how much. (I
usually keep them Visible.No but lately just show them to see if that helps.)
I just want folks to be able to click a button and the data (if any) is
copied over into the bill record. I used to have the code in a validation
macro but it didn't work there either. I have the code behind a button:

Private Sub UpdateSubs_Click()

Me.MailPartStmtCycleCount = Me.MailPartStmtCycleCopy
Me.MailPartStmtCount = Me.MailPartStmtCopy
Me.MailPartStmtFee = Me.MailPartStmtCount * 1.25

Me.AmdmtNum = Me.CountAmdmt
Me.AmdmtFee = Me.AmtDueAmdmt

If Me.AmdmtNum > 0 Then
Me.InclAmdmtFee = -1
End If

Me.PartSearchFeeCount = Me.PartSearchFeeCopy
Me.PartSearchFee = Me.PartSearchFeeCount * 10
End Sub

It worked at the time but now it doesn't. I've tried to switch the order
but can't make sense of this.

Also, here is how I'm pulling the data up from the subsub form for Amendments:

[AmtDueAmdmt] Control Source is:
=IIf(IsError([RPSAdminBillSubAmdmts].[Form]![AmdmtAmtDue]),0,[RPSAdminBillSu
bAmdmts].[Form]![AmdmtAmtDue])
So the data is sitting there in the field and I've checked the names
backwards and forwards. Also, if I separate the amendment pieces out to a
button of their own, they work. But for how long?

I'm not a programmer as I'm sure you know by now but would appreciate any
assistance or education you'd mind sharing.

I am stumped and my itsy bitsy Access reputation is going down the tube.
Help?!?!?

Thanks in advance for any assistance.
 
Back
Top