G
Guest
I have this form that facilitates data entry into my table. There is a
calculated control on the form, which shows a product of two numbers entered
by the user. I was told that storing calculated control's data in a table is
not wise, but I think in my case it is working perfectly. I also have two
radio buttons that control which field in my table the number from my
calculated control passes into. If I click credit it is sent into the credit
amount field and if i click debit it passes into the debit amount field. To
achieve this I used two hidden textboxes that are each bound to a field.
txtCreditAmount is bound to the Credit_Amount field and txtDebitAmount is
bound to the Debit_Amound field. So if there is a number in my unbound
calculated control by selecting the appropriate radio button the content of
my calculated control is sent to on of the textboxes which are recorded in
the table.
I have 2 questions...
First, is there a simpler way of doing this? It works perfectly, but
something tells me there should be an easier way of doing this.
Secondly, When I use my navigator buttons the stored number does not show up
in the calculated control, only when I delete a record with the help of my
delete button, then the next record's amount shows up, but when I am trying
to navigate nothing happens....
Any ideas????
Here is the code:
Private Sub btnCalculate_Click()
Call RecordedAmount_AfterUpdate
Call frmRad_AfterUpdate
End Sub
Private Sub frmRad_AfterUpdate()
If Me.frmRad = 1 Then
Me.txtDebitAmount = RecordedAmount
Else
Me.txtCreditAmount = RecordedAmount
End If
End Sub
Private Sub RecordedAmount_AfterUpdate()
Me.RecordedAmount = Round(Me.Exchange_Rate * Me.For_Cur_Amount, 2)
End Sub
Private Sub btnAddRecord_Click()
On Error GoTo Err_btnAddRecord_Click
DoCmd.GoToRecord , , acNewRec
RecordedAmount.SetFocus
Me.RecordedAmount.Text = ""
Exit_btnAddRecord_Click:
Exit Sub
Err_btnAddRecord_Click:
MsgBox Err.Description
Resume Exit_btnAddRecord_Click
End Sub
Private Sub btnDeleteDecord_Click()
On Error GoTo Err_btnDeleteDecord_Click
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
RecordedAmount.SetFocus
Me.RecordedAmount.Text = ""
Exit_btnDeleteDecord_Click:
Exit Sub
Err_btnDeleteDecord_Click:
MsgBox Err.Description
Resume Exit_btnDeleteDecord_Click
End Sub
Private Sub btnExitForm_Click()
On Error GoTo Err_btnExitForm_Click
DoCmd.Close
Exit_btnExitForm_Click:
Exit Sub
Err_btnExitForm_Click:
MsgBox Err.Description
Resume Exit_btnExitForm_Click
End Sub
Private Sub btnExitApp_Click()
On Error GoTo Err_btnExitApp_Click
DoCmd.Quit
Exit_btnExitApp_Click:
Exit Sub
Err_btnExitApp_Click:
MsgBox Err.Description
Resume Exit_btnExitApp_Click
End Sub
Private Sub btnNext_Click()
On Error GoTo Err_btnNext_Click
Screen.PreviousControl.SetFocus
DoCmd.FindNext
Exit_btnNext_Click:
Exit Sub
Err_btnNext_Click:
MsgBox Err.Description
Resume Exit_btnNext_Click
End Sub
Private Sub btnPrevious_Click()
On Error GoTo Err_btnPrevious_Click
DoCmd.GoToRecord , , acPrevious
Exit_btnPrevious_Click:
Exit Sub
Err_btnPrevious_Click:
MsgBox Err.Description
Resume Exit_btnPrevious_Click
End Sub
Private Sub btnNextRecord_Click()
On Error GoTo Err_btnNextRecord_Click
DoCmd.GoToRecord , , acNext
Exit_btnNextRecord_Click:
Exit Sub
Err_btnNextRecord_Click:
MsgBox Err.Description
Resume Exit_btnNextRecord_Click
End Sub
Private Sub txtDateOfRequisition_AfterUpdate()
Me.txtDateOfRequisition.
End Sub
calculated control on the form, which shows a product of two numbers entered
by the user. I was told that storing calculated control's data in a table is
not wise, but I think in my case it is working perfectly. I also have two
radio buttons that control which field in my table the number from my
calculated control passes into. If I click credit it is sent into the credit
amount field and if i click debit it passes into the debit amount field. To
achieve this I used two hidden textboxes that are each bound to a field.
txtCreditAmount is bound to the Credit_Amount field and txtDebitAmount is
bound to the Debit_Amound field. So if there is a number in my unbound
calculated control by selecting the appropriate radio button the content of
my calculated control is sent to on of the textboxes which are recorded in
the table.
I have 2 questions...
First, is there a simpler way of doing this? It works perfectly, but
something tells me there should be an easier way of doing this.
Secondly, When I use my navigator buttons the stored number does not show up
in the calculated control, only when I delete a record with the help of my
delete button, then the next record's amount shows up, but when I am trying
to navigate nothing happens....
Any ideas????
Here is the code:
Private Sub btnCalculate_Click()
Call RecordedAmount_AfterUpdate
Call frmRad_AfterUpdate
End Sub
Private Sub frmRad_AfterUpdate()
If Me.frmRad = 1 Then
Me.txtDebitAmount = RecordedAmount
Else
Me.txtCreditAmount = RecordedAmount
End If
End Sub
Private Sub RecordedAmount_AfterUpdate()
Me.RecordedAmount = Round(Me.Exchange_Rate * Me.For_Cur_Amount, 2)
End Sub
Private Sub btnAddRecord_Click()
On Error GoTo Err_btnAddRecord_Click
DoCmd.GoToRecord , , acNewRec
RecordedAmount.SetFocus
Me.RecordedAmount.Text = ""
Exit_btnAddRecord_Click:
Exit Sub
Err_btnAddRecord_Click:
MsgBox Err.Description
Resume Exit_btnAddRecord_Click
End Sub
Private Sub btnDeleteDecord_Click()
On Error GoTo Err_btnDeleteDecord_Click
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
RecordedAmount.SetFocus
Me.RecordedAmount.Text = ""
Exit_btnDeleteDecord_Click:
Exit Sub
Err_btnDeleteDecord_Click:
MsgBox Err.Description
Resume Exit_btnDeleteDecord_Click
End Sub
Private Sub btnExitForm_Click()
On Error GoTo Err_btnExitForm_Click
DoCmd.Close
Exit_btnExitForm_Click:
Exit Sub
Err_btnExitForm_Click:
MsgBox Err.Description
Resume Exit_btnExitForm_Click
End Sub
Private Sub btnExitApp_Click()
On Error GoTo Err_btnExitApp_Click
DoCmd.Quit
Exit_btnExitApp_Click:
Exit Sub
Err_btnExitApp_Click:
MsgBox Err.Description
Resume Exit_btnExitApp_Click
End Sub
Private Sub btnNext_Click()
On Error GoTo Err_btnNext_Click
Screen.PreviousControl.SetFocus
DoCmd.FindNext
Exit_btnNext_Click:
Exit Sub
Err_btnNext_Click:
MsgBox Err.Description
Resume Exit_btnNext_Click
End Sub
Private Sub btnPrevious_Click()
On Error GoTo Err_btnPrevious_Click
DoCmd.GoToRecord , , acPrevious
Exit_btnPrevious_Click:
Exit Sub
Err_btnPrevious_Click:
MsgBox Err.Description
Resume Exit_btnPrevious_Click
End Sub
Private Sub btnNextRecord_Click()
On Error GoTo Err_btnNextRecord_Click
DoCmd.GoToRecord , , acNext
Exit_btnNextRecord_Click:
Exit Sub
Err_btnNextRecord_Click:
MsgBox Err.Description
Resume Exit_btnNextRecord_Click
End Sub
Private Sub txtDateOfRequisition_AfterUpdate()
Me.txtDateOfRequisition.
End Sub