Since you are using really bad naming, you need to enclose the name of the
form in brackets or it may cause problems:
Docmd.OpenForm "[Members & Designees Form]"
Do I also need to alter the next two "docmd" commands? for example, should
Docmd.Close acForm, Me.Name, acSaveNo ... be changed to Docmd.Close
ac(my form name), Me.(name of what?), acSaveNo
No, acForm is a constant that tells the Close method you want to close the
form.
Me.Name tells the Close method the name of the form you want to close
acSaveNo means don't save any changes to the form (not data, just changes to
the form object)
what do I do next?
Just to be sure the code is in the correct place, it needs to be in the
Before Update event of the check box. I don't know what your check box name
is, so I just made one up.
Private Sub chkCurrent_BeforeUpdate(Cancel As Integer)
To be sure it is correct, in form design view, select the check box and open
the properties dialog.
Select the events tab.
Find the text box labeled Before Update
Click on the small button with the 3 dots to the right of it.
The VB Editor will open with the cursor positioned in the event procedure.
Paste the code in there but don't include the Private Sub or End sub lines,
they are already there.
Now when you click the check box, the code will execute.
--
Dave Hargis, Microsoft Access MVP
smoknjo said:
Dave, WOW ... thank you!
I cut and pasted the SQL code (which I've never used before) ... I changed ...
Case vbYes
Docmd.OpenForm "frmAddMember" ... to Docmd.OpenForm "Members &
Designees Form
Do I also need to alter the next two "docmd" commands? for example, should
Docmd.Close acForm, Me.Name, acSaveNo ... be changed to Docmd.Close
ac(my form name), Me.(name of what?), acSaveNo
also ... once I have entered in all that code ... what do I do next? How do
I save tell ACCESS to refer to this code?
Thank you Dave
:
Use the Before Update event of the check box control:
Private Sub chkCurrent_BeforeUpdate(Cancel As Integer)
Dim lngAnswer As Long
If Me.chkCurrent.OldValue = True and Me.chkCurrent = False Then
lngAnswer = Msgbox("Yes = Change Status and Add New Member" &
vbNewLine & _
"No = Change Status Only" & vbNewLine & _
"Cancel = Do Not Change Status", vbYesNoCancel + vbQuestion, _
"MemberStatusChange")
Select Case lngAnswer
Case vbYes
Docmd.OpenForm "frmAddMember"
Docmd.Close acForm, Me.Name, acSaveNo
Case vbNo
Docmd.Close acForm, Me.Name, acSaveNo
Case vbCancel
Cancel = True
End Select
End If
Ens Sub
--
Dave Hargis, Microsoft Access MVP
:
I have created a database that will track board members. One of the records
on my member table is "current" ... the field is a yes/no field. I have
reports that will display all members, all members of a specific board and
all members of that board being yes or no ... is there a way on a form, that
if a user is changing the member status from yes to no, that ACCESS will
prompt them with a question that says "would you like to add a new member?"
... if they click yes, I can take them to another "add new member" form, if
no, they can exit to the main menu?
thank you for your tutelage