Syntax to divide form values and update table as percentage with 2 decimals; close form and open another form
Posted on 2013-12-12
The following is the VBA code I wrote to update a table from a form. I have two questions.
First I want to divide the form entries:
Me.txtXM / Me.txtTM and update the table field XMPERC as a Percentage with 2 decimal places.
Second I need to close the open form frmSR1 and reopen frmEvalMenu.
What is the syntax for this?
Private Sub Command27_Click()
'Update tbl_SR1 with Blood Data
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("tbl_SR1", dbOpenDynaset)
rs.Fields("ProviderID") = Me.Text16
rs.Fields("XM") = Me.txtXM
rs.Fields("TX") = Me.txtTX
rs.Fields("RptDate") = Me.Text20
rs.Fields("XMPERC") = Format(Me.txtXM / Me.txtTX, "000.00")
Set rs = Nothing
'Clear All Selections and Return to Physician Evaluation Menu
DoCmd.Close acForm, "frm_SR1"