Link to home
Start Free TrialLog in
Avatar of GPSPOW
GPSPOWFlag for United States of America

asked on

Syntax to divide form values and update table as percentage with 2 decimals; close form and open another form

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.AddNew
     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")
     
     rs.Update
     
     rs.Close
     
     Set rs = Nothing
     
     'Clear All Selections and Return to Physician Evaluation Menu
     
     DoCmd.Close acForm, "frm_SR1"
     
 End Sub

thanks

Glen
SOLUTION
Avatar of mbizup
mbizup
Flag of Kazakhstan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of GPSPOW

ASKER

Both solutions worked perfectly

Thanks

glen
Glad to help :)