radio buttons

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

Guest

I have a calculated control on my form and two fields in my database. I know,
I should not record a calculated control's content into a table, but I still
want to do it regardless.
My calculated control: txt RecordedAmount
One of the fields in the tables is: Debit Amount
The other is :Credit Amount
radiobutton1:radDebit
radiobutton2:radCredit

I get the product in txtRecordedAmount by multiplying two numbers and that
is what I want to record in my table.
However, I want it so when the user clicks radDebit then the amount form my
caculated control gets passed into the Debit Amount field of my table and
when the user presses radCredit the amount from thet txtRecordedAmount field
passes into the Credit Amount field of my database.

I hope this was a clear enough explanation...

Any suggestions?
 
Red_Star20 said:
I have a calculated control on my form and two fields in my database. I know,
I should not record a calculated control's content into a table, but I still
want to do it regardless.
My calculated control: txt RecordedAmount
One of the fields in the tables is: Debit Amount
The other is :Credit Amount
radiobutton1:radDebit
radiobutton2:radCredit

I get the product in txtRecordedAmount by multiplying two numbers and that
is what I want to record in my table.
However, I want it so when the user clicks radDebit then the amount form my
caculated control gets passed into the Debit Amount field of my table and
when the user presses radCredit the amount from thet txtRecordedAmount field
passes into the Credit Amount field of my database.


Once again, there is no need to store these values once you
store the radio button's frame and the recorded amount.

If you really want to go against the grain, add hidden(?),
bound text boxes for credit amount and for debit amount.
Then calculate the recorded amount using VBA code in the
AfterUpdate event of the text box's for each of the values
used in the calculation. Then you can use an If statement
to decide where to put it.

Me.txtRecordedAmount = A * B
If Me.frmRad = 1 Then
Me.txtDebitAmount = txtRecordedAmount
Else
Me.txtCreditAmount = txtRecordedAmount
End If
 
I'll give it a shot tomorrow at work... Thanks

Marshall Barton said:
Once again, there is no need to store these values once you
store the radio button's frame and the recorded amount.

If you really want to go against the grain, add hidden(?),
bound text boxes for credit amount and for debit amount.
Then calculate the recorded amount using VBA code in the
AfterUpdate event of the text box's for each of the values
used in the calculation. Then you can use an If statement
to decide where to put it.

Me.txtRecordedAmount = A * B
If Me.frmRad = 1 Then
Me.txtDebitAmount = txtRecordedAmount
Else
Me.txtCreditAmount = txtRecordedAmount
End If
 
This is what I have now... and calculations go smoothl, but for some weird
reason it still does not record into the table:

Private Sub btnCalculate_Click()
Call RecordedAmount_AfterUpdate
Call frmRad_AfterUpdate
End Sub



Private Sub frmRad_AfterUpdate()
If Me.frmRad = 1 Then
Me.txtDebitAmount = txtRecordedAmount
Else
Me.txtCreditAmount = txtRecordedAmount
End If
End Sub

Private Sub RecordedAmount_AfterUpdate()
Me.RecordedAmount = Round(Me.Exchange_Rate * Me.For_Cur_Amount, 2)
End Sub



Any ideas?
 
I don't think I understand how that code works. What I was
suggesting was:

Private Sub For_Cur_Amount_AfterUpdate()
Me.RecordedAmount = Round(Me.Exchange_Rate _
* Me.For_Cur_Amount, 2)
End Sub

Private Sub Exchange_Rate_AfterUpdate()
Me.RecordedAmount = Round(Me.Exchange_Rate _
* Me.For_Cur_Amount, 2)
End Sub

Private Sub frmRad_AfterUpdate()
If Me.frmRad = 1 Then
Me.txtDebitAmount = txtRecordedAmount
Else
Me.txtCreditAmount = txtRecordedAmount
End If
End Sub

I don't see where btnCalculate comes into this situation so
I could be way off base with my idea.

I think maybe the reason that the calculated values are not
making it into the table is that you forgot to bind the text
boxes to their related table fields.
 
I figured out what was wrong. Under the Private Sub frmRad_AfterUpdate()
instead of calling my Recorded Amount textbox "txtRecordedAmount", I just
called it "RecordedAmount" so Access had no idea what I was referreing to.

Do you know how to reset an Autonumber field in a table?

I have this table and I deleted all the records, but somehow the autonumber
field continues where it left off...

Thank for all your help.

Marshall Barton said:
I don't think I understand how that code works. What I was
suggesting was:

Private Sub For_Cur_Amount_AfterUpdate()
Me.RecordedAmount = Round(Me.Exchange_Rate _
* Me.For_Cur_Amount, 2)
End Sub

Private Sub Exchange_Rate_AfterUpdate()
Me.RecordedAmount = Round(Me.Exchange_Rate _
* Me.For_Cur_Amount, 2)
End Sub

Private Sub frmRad_AfterUpdate()
If Me.frmRad = 1 Then
Me.txtDebitAmount = txtRecordedAmount
Else
Me.txtCreditAmount = txtRecordedAmount
End If
End Sub

I don't see where btnCalculate comes into this situation so
I could be way off base with my idea.

I think maybe the reason that the calculated values are not
making it into the table is that you forgot to bind the text
boxes to their related table fields.
--
Marsh
MVP [MS Access]



Red_Star20 said:
This is what I have now... and calculations go smoothl, but for some weird
reason it still does not record into the table:

Private Sub btnCalculate_Click()
Call RecordedAmount_AfterUpdate
Call frmRad_AfterUpdate
End Sub


Private Sub frmRad_AfterUpdate()
If Me.frmRad = 1 Then
Me.txtDebitAmount = txtRecordedAmount
Else
Me.txtCreditAmount = txtRecordedAmount
End If
End Sub

Private Sub RecordedAmount_AfterUpdate()
Me.RecordedAmount = Round(Me.Exchange_Rate * Me.For_Cur_Amount, 2)
End Sub
 
Red_Star20 said:
I figured out what was wrong. Under the Private Sub frmRad_AfterUpdate()
instead of calling my Recorded Amount textbox "txtRecordedAmount", I just
called it "RecordedAmount" so Access had no idea what I was referreing to.

Do you know how to reset an Autonumber field in a table?

I have this table and I deleted all the records, but somehow the autonumber
field continues where it left off...


After deleting all the records, Compact the file to reset
the Autonumber starting value.
 
Back
Top