Open a form when check box checked

Jonny

Registered User.
Local time
Today, 10:41
Joined
Aug 12, 2005
Messages
144
I want to write some code when I'm checking "Purchased (Y/N)" field then opening existing form with filled fields.
It must be something like:
Code:
Private Sub Purchased_(Y/N)_Click()
...
            DoCmd.OpenForm
...
End Sub
 

Attachments

  • untitled.JPG
    untitled.JPG
    13.5 KB · Views: 172
From a form then fine, but not from a table.
 
This in not a table , this is a form in datasheet view.
 
Naming the form Table1 confused me. In design mode go to the property sheet for the control and press the "..." button on the row where the OnClick event is located. Then just enter your code.
 
When I checking the checkbox will be opened modal form where in the fields will be values of current record.
Could you help with a code ?
 
acDialog will cause the form to be modal. Can you use a WhereCondition to get the next form to the correct record? Put some code together and post it here and let us know what is not happening correctly and we can help.
 
Please find below event of "check box click"
Code:
Private Sub CarPurchased_Click()
    On Error GoTo CarPurchased_Err
    Dim intAnswer As Integer
    Dim strSQL As String
    intAnswer = MsgBox("Would you like to update new cars?", vbQuestion + vbYesNo, "Cars Purchased")    
    If intAnswer = vbYes Then
        DoCmd.OpenForm "CarPurchased", Datamode:=acFormAdd, WindowMode:=acDialog, OpenArgs:=CurrentRecord
        DoCmd.SetWarnings False
        DoCmd.SetWarnings True
        MsgBox "The new value has been added to the list.", vbInformation, "Value Added"
        Response = acDataErrAdded
    Else
        MsgBox "Please choose a value from the list.", vbInformation, "Value Not in List"
        Response = acDataErrContinue
    End If
CarPurchased_Exit:
Exit Sub
CarPurchased_Err:
    MsgBox Err.Description, vbCritical, "Error"
Resume CarPurchased_Exit
End Sub
In modal form I would like to show fields of current record and it is opening empty.
 

Attachments

  • untitled.JPG
    untitled.JPG
    13.5 KB · Views: 171
So your "CarPurchased" form does not share a RecordSource with the 1st form? It is necessary to add a completely new record?
 

Users who are viewing this thread

Back
Top Bottom