Update a record from form

G

Guest

Hello,

I have a form that is based on a table called "tbl_sub_procedures_temp". I
have a field in this table called "Comp Status" which is a text field. In
this field, I want to store two values, either "Pass" or "Fail".

On the form, I have two check boxes in an option group (frame24). Value 1
of the option group is labeled "Pass" and Value 2 of the option group is
labeled "Fail".

I want the user to scroll through the records on the form and flag all
records as either Pass or Fail. I want to store this value in the "Comp
Status" field as either "Pass" or "Fail" based on which of the two check
boxes were checked.

After all records have been reviewed and either of the two check boxes have
been checked, I want to update a field in another table, which is not bound
to the form in anyway. This table is "tbl_Master".

How can I achieve this?
 
G

Guest

You can use an Update query. You did not say what you want to update under
what conditions, or when or how you want to initiate this update.

I would suggest using command buttons for the Pass/Fail selection. Keeping
the check boxes in the correct state will require more coding and IMHO be
easier for a user to understand.
 
G

Guest

I want to update when each record is scrolled and I would like to keep the
check boxes on the form. Also, I want to hard-code through VBA. How can I
do this?
 
G

Guest

If you want to update record by record, a query will not be necessary. You
will need a control on your form bound to the field that will contain Pass or
Fail. It can be hidden so the user sees only the check boxes.
You will need code in the After Update event of both the the check boxes and
in the form Current event.

Private Sub chkPass_After Update()
If Me.chkPass = True Then
Me.txtCompStatus = "Pass"
Me.chkFail = False
ElseIf Me.chkPass = False Then
If Me.chkFail = False Then
Me.txtCompStatus = Null
End If
End If
End Sub

Private Sub chkFail_After Update()
If Me.chkFail = True Then
Me.txtCompStatus = "Fail"
Me.chkPass = False
ElseIf Me.chkFail = False Then
If Me.chkPass = False
Me.txtCompStatus = Null
End If
End If
End Sub

Private Sub Form_Current()

Me.chkPass = Me.txtCompStatus = "Pass"
Me.chkFail = Me.txtCompStatus = "Fail"
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top