Another Unbound Form with Option group Problem

  • Thread starter Thread starter jastarkey
  • Start date Start date
J

jastarkey

Hello!

I have inherited a database with an unbound form with various text
fields. This has always worked fine but since a request was made to
put an option set in - I'm confused (I have always worked with bound
forms in the past). Here is the code. I'm hoping this is really easy
I'm just too dense to see it.
------------------------------------------------------------------------------------------------------------------------------
Private Sub close_button_Click()
On Error GoTo Err_close_button_Click
strsql = "select * from doc_log"
Set rclogs = db.OpenRecordset(strsql)
rclogs.AddNew
rclogs![LOG #] = Me.LOG_Num
rclogs![DOC_NUMBER] = Me.Form_DOC_NUMBER
rclogs![DOC_NAME] = Me.Form_DOC_NAME
rclogs![DocType] = Me.DocTypeBox
rclogs![RevisionNumber] = Me.RevisionNumber
rclogs![RevisionReason] = Me.RevisionReason
rclogs![DocControlAssignedTo] = Me.DocControlAssignBox
rclogs![ImmediateRelease] = Me.optImmediateRelease
rclogs![DATE_OUT] = Me.Form_DATE_OUT
rclogs![Initiator] = Me.Form_Initiator
rclogs![Passed to1] = Me.Form_Passedto1
rclogs![Date_passed1] = Me.Form_Date_passed1
rclogs![Comment] = Me.Form_Comment
rclogs![ProductCategory] = Me.ProdCategoryBox
rclogs.Update
rclogs.Close
MsgBox "New record added " & Me.LOG_Num
Me.Undo
DoCmd.Close acForm, "data_admin_add", acSaveNo

Exit_close_button_Click:
Exit Sub

Err_close_button_Click:
MsgBox Err.Description
Resume Exit_close_button_Click

End Sub
------------------------------------------------------------------------------------------------------------------------------

This statement: rclogs![ImmediateRelease] = Me.optImmediateRelease
is the option group. All I want is to choose yes or no!

How can this be done? Thanks in advance for any help!

J
 
J,
you can use a variable and if statement to get the value from the option
group.

Dim varReleaseState as Variant
If Me.optImmediateRelease = 1 Then
varReleaseState = "Yes"
ElseIf Me.optImmediateRelease = 2 Then
varReleaseState = "No"
Else
varReleaseState = Null
End if

put the above code above the line starting with
strsql = "select * from doc_log"

change the line
rclogs![ImmediateRelease] = Me.optImmediateRelease
to
rclogs![ImmediateRelease] = varReleaseState


Jeanette Cunningham -- Melbourne Victoria Australia


Hello!

I have inherited a database with an unbound form with various text
fields. This has always worked fine but since a request was made to
put an option set in - I'm confused (I have always worked with bound
forms in the past). Here is the code. I'm hoping this is really easy
I'm just too dense to see it.
------------------------------------------------------------------------------------------------------------------------------
Private Sub close_button_Click()
On Error GoTo Err_close_button_Click
strsql = "select * from doc_log"
Set rclogs = db.OpenRecordset(strsql)
rclogs.AddNew
rclogs![LOG #] = Me.LOG_Num
rclogs![DOC_NUMBER] = Me.Form_DOC_NUMBER
rclogs![DOC_NAME] = Me.Form_DOC_NAME
rclogs![DocType] = Me.DocTypeBox
rclogs![RevisionNumber] = Me.RevisionNumber
rclogs![RevisionReason] = Me.RevisionReason
rclogs![DocControlAssignedTo] = Me.DocControlAssignBox
rclogs![ImmediateRelease] = Me.optImmediateRelease
rclogs![DATE_OUT] = Me.Form_DATE_OUT
rclogs![Initiator] = Me.Form_Initiator
rclogs![Passed to1] = Me.Form_Passedto1
rclogs![Date_passed1] = Me.Form_Date_passed1
rclogs![Comment] = Me.Form_Comment
rclogs![ProductCategory] = Me.ProdCategoryBox
rclogs.Update
rclogs.Close
MsgBox "New record added " & Me.LOG_Num
Me.Undo
DoCmd.Close acForm, "data_admin_add", acSaveNo

Exit_close_button_Click:
Exit Sub

Err_close_button_Click:
MsgBox Err.Description
Resume Exit_close_button_Click

End Sub
------------------------------------------------------------------------------------------------------------------------------

This statement: rclogs![ImmediateRelease] = Me.optImmediateRelease
is the option group. All I want is to choose yes or no!

How can this be done? Thanks in advance for any help!

J
 
Back
Top