Option Buttons

law

Registered User.
Local time
Today, 13:13
Joined
Feb 14, 2004
Messages
26
I currently have a form which has fields in it and I also have two option buttons these option buttons are OPEN and CLOSE. Also I have an update button on the form so for example if the user was to select the option OPEN and then click on the update button the record would be saved. But if the user selects the option CLOSE then clicks on the update button I would like the form to be deleted from the database. I have put the code below of what I think needs to make it work. But now i am getting a error message saying "You entered an expression that has no value"

Can anyone help with this please??

Private Sub cmdJobDetailsUpdate_Click()
Dim answer As Integer

If Me.optJobClose.Value = True Then

answer = MsgBox("Are you sure you want to close this job", vbYesNo, "Update Job Details")

If answer = vbYes Then

DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdDeleteRecord

End If

Else

If Me.optJobOpen.Value = True Then

DoCmd.RunCommand acSaveRecord

End If

End If

End Sub
 
If i knew your option box name i could of used a case select satement, but the below should work, and acCmdUndo is what you were looking for.

Code:
Private Sub cmdJobDetailsUpdate_Click()
Dim booJobOpen As Boolean
Dim booJobClose As Boolean
Dim strAnswer As String

booJobOpen = Me.optJobOpen.Value
booJobClose = Me.optJobClose.Value
strAnswer = MsgBox("Are you sure you want to close this job", vbYesNo, "Update Job Details")

    If booJobClose = True And strAnswer = vbYes Then
        DoCmd.RunCommand acCmdUndo
    ElseIf booJobOpen = True Then
        DoCmd.RunCommand acSaveRecord
    End If

End Sub
________
SUZUKI XL7 HISTORY
 
Last edited:
Thanks for that but I have altered my code to the same as yours but I am still getting the same error message as before?

Help??

Thanks
 
Am I reading this right?

law said:
I currently have a form which has fields in it and I also have two option buttons these option buttons are OPEN and CLOSE. Also I have an update button on the form so for example if the user was to select the option OPEN and then click on the update button the record would be saved. But if the user selects the option CLOSE then clicks on the update button I would like the form to be deleted from the database.

Forms don't store data they just let you enter it. If you click the close or exit without entering any Data why would you need a Coded "Close" button to delete the form? Or an Update either for that matter the Tool bar Save button works just fine.
 
WHAT I MEANT IS THAT the text boxes on my form get data from their field for example the address text box on a form can be bound to a table data field.
So you dont understand!!!!
 
Ok

law said:
WHAT I MEANT IS THAT the text boxes on my form get data from their field for example the address text box on a form can be bound to a table data field.
So you dont understand!!!!

Ok now I do. Sorry to misunderstand.
 

Users who are viewing this thread

Back
Top Bottom