Z
zizi2007 via AccessMonster.com
hello,
I have a form with 2 toggle buttons on it, to open 2 separate forms. Unless
I set the AllowEdits to Yes in the properties in the form design, these two
toggle buttons are disabled.
how can I change that? I don't want the user to be able to edit any of the
fields (I have a separate edit button, so that I can archive the record and
make a new record (for historical purposes)) .
Thanks in advance for your help.
Z
------------------------------------------------------------------------------
--------------------------------
here is the code:
Option Compare Database
'-----------------------------------------------------------------------------
---------------------------------
Sub Form_Current()
On Error GoTo Form_Current_Err
If GroupsFormIsOpen() Then FilterGroupsForm
If RatesFormIsOpen() Then FilterRatesForm
Me!cmdUndo.Enabled = False
Form_Current_Exit:
Exit Sub
Form_Current_Err:
MsgBox Error$
Resume Form_Current_Exit
End Sub
'-----------------------------------------------------------------------------
---------------------------------
Sub cmdUndo_Click()
On Error GoTo cmdUndo_Click_Err
DoCmd.RunCommand acCmdUndo
cmdUndo_Click_Exit:
Exit Sub
cmdUndo_Click_Err:
MsgBox Error$
Resume cmdUndo_Click_Exit
End Sub
'-----------------------------------------------------------------------------
---------------------------------
Private Sub Form_Dirty(Cancel As Integer)
Me!cmdUndo.Enabled = True
End Sub
'-----------------------------------------------------------------------------
---------------------------------
Sub ToggleLink_Click()
On Error GoTo ToggleLink_Click_Err
If GroupsFormIsOpen() Then
CloseGroupsForm
Else
OpenGroupsForm
FilterGroupsForm
End If
ToggleLink_Click_Exit:
Exit Sub
ToggleLink_Click_Err:
MsgBox Error$
Resume ToggleLink_Click_Exit
End Sub
'-----------------------------------------------------------------------------
---------------------------------
Private Sub FilterGroupsForm()
If Me.NewRecord Then
Forms![Groups].DataEntry = True
Forms![Groups].OrderByOn = True
Else
Forms![Groups].Filter = "[GroupID] = " & """" & Me.[Group_ID] & """"
Forms![Groups].FilterOn = True
Forms![Groups].OrderByOn = True
End If
End Sub
'-----------------------------------------------------------------------------
---------------------------------
Private Sub OpenGroupsForm()
DoCmd.OpenForm "Groups"
If Not Me.[ToggleLink] Then Me![ToggleLink] = True
End Sub
'-----------------------------------------------------------------------------
---------------------------------
Private Sub CloseGroupsForm()
DoCmd.Close acForm, "Groups"
If Me![ToggleLink] Then Me![ToggleLink] = False
End Sub
'-----------------------------------------------------------------------------
---------------------------------
Private Function GroupsFormIsOpen()
GroupsFormIsOpen = (SysCmd(acSysCmdGetObjectState, acForm, "Groups") And
acObjStateOpen) <> False
End Function
'-----------------------------------------------------------------------------
---------------------------------
Sub RatesToggle_Click()
On Error GoTo RatesToggle_Click_Err
If RatesFormIsOpen() Then
CloseRatesForm
Else
OpenRatesForm
FilterRatesForm
End If
RatesToggle_Click_Exit:
Exit Sub
RatesToggle_Click_Err:
MsgBox Error$
Resume RatesToggle_Click_Exit
End Sub
'-----------------------------------------------------------------------------
---------------------------------
Private Sub FilterRatesForm()
If Me.NewRecord Then
Forms![Rates].DataEntry = True
Else
Forms![Rates].Filter = "[GroupID] = " & """" & Me.[Group_ID] & """"
Forms![Rates].FilterOn = True
End If
End Sub
'-----------------------------------------------------------------------------
---------------------------------
Private Sub OpenRatesForm()
DoCmd.OpenForm "Rates"
If Not Me.[RatesToggle] Then Me![RatesToggle] = True
End Sub
'-----------------------------------------------------------------------------
---------------------------------
Private Sub CloseRatesForm()
DoCmd.Close acForm, "Rates"
If Me![RatesToggle] Then Me![RatesToggle] = False
End Sub
'-----------------------------------------------------------------------------
---------------------------------
Private Function RatesFormIsOpen()
RatesFormIsOpen = (SysCmd(acSysCmdGetObjectState, acForm, "Rates") And
acObjStateOpen) <> False
End Function
I have a form with 2 toggle buttons on it, to open 2 separate forms. Unless
I set the AllowEdits to Yes in the properties in the form design, these two
toggle buttons are disabled.
how can I change that? I don't want the user to be able to edit any of the
fields (I have a separate edit button, so that I can archive the record and
make a new record (for historical purposes)) .
Thanks in advance for your help.
Z
------------------------------------------------------------------------------
--------------------------------
here is the code:
Option Compare Database
'-----------------------------------------------------------------------------
---------------------------------
Sub Form_Current()
On Error GoTo Form_Current_Err
If GroupsFormIsOpen() Then FilterGroupsForm
If RatesFormIsOpen() Then FilterRatesForm
Me!cmdUndo.Enabled = False
Form_Current_Exit:
Exit Sub
Form_Current_Err:
MsgBox Error$
Resume Form_Current_Exit
End Sub
'-----------------------------------------------------------------------------
---------------------------------
Sub cmdUndo_Click()
On Error GoTo cmdUndo_Click_Err
DoCmd.RunCommand acCmdUndo
cmdUndo_Click_Exit:
Exit Sub
cmdUndo_Click_Err:
MsgBox Error$
Resume cmdUndo_Click_Exit
End Sub
'-----------------------------------------------------------------------------
---------------------------------
Private Sub Form_Dirty(Cancel As Integer)
Me!cmdUndo.Enabled = True
End Sub
'-----------------------------------------------------------------------------
---------------------------------
Sub ToggleLink_Click()
On Error GoTo ToggleLink_Click_Err
If GroupsFormIsOpen() Then
CloseGroupsForm
Else
OpenGroupsForm
FilterGroupsForm
End If
ToggleLink_Click_Exit:
Exit Sub
ToggleLink_Click_Err:
MsgBox Error$
Resume ToggleLink_Click_Exit
End Sub
'-----------------------------------------------------------------------------
---------------------------------
Private Sub FilterGroupsForm()
If Me.NewRecord Then
Forms![Groups].DataEntry = True
Forms![Groups].OrderByOn = True
Else
Forms![Groups].Filter = "[GroupID] = " & """" & Me.[Group_ID] & """"
Forms![Groups].FilterOn = True
Forms![Groups].OrderByOn = True
End If
End Sub
'-----------------------------------------------------------------------------
---------------------------------
Private Sub OpenGroupsForm()
DoCmd.OpenForm "Groups"
If Not Me.[ToggleLink] Then Me![ToggleLink] = True
End Sub
'-----------------------------------------------------------------------------
---------------------------------
Private Sub CloseGroupsForm()
DoCmd.Close acForm, "Groups"
If Me![ToggleLink] Then Me![ToggleLink] = False
End Sub
'-----------------------------------------------------------------------------
---------------------------------
Private Function GroupsFormIsOpen()
GroupsFormIsOpen = (SysCmd(acSysCmdGetObjectState, acForm, "Groups") And
acObjStateOpen) <> False
End Function
'-----------------------------------------------------------------------------
---------------------------------
Sub RatesToggle_Click()
On Error GoTo RatesToggle_Click_Err
If RatesFormIsOpen() Then
CloseRatesForm
Else
OpenRatesForm
FilterRatesForm
End If
RatesToggle_Click_Exit:
Exit Sub
RatesToggle_Click_Err:
MsgBox Error$
Resume RatesToggle_Click_Exit
End Sub
'-----------------------------------------------------------------------------
---------------------------------
Private Sub FilterRatesForm()
If Me.NewRecord Then
Forms![Rates].DataEntry = True
Else
Forms![Rates].Filter = "[GroupID] = " & """" & Me.[Group_ID] & """"
Forms![Rates].FilterOn = True
End If
End Sub
'-----------------------------------------------------------------------------
---------------------------------
Private Sub OpenRatesForm()
DoCmd.OpenForm "Rates"
If Not Me.[RatesToggle] Then Me![RatesToggle] = True
End Sub
'-----------------------------------------------------------------------------
---------------------------------
Private Sub CloseRatesForm()
DoCmd.Close acForm, "Rates"
If Me![RatesToggle] Then Me![RatesToggle] = False
End Sub
'-----------------------------------------------------------------------------
---------------------------------
Private Function RatesFormIsOpen()
RatesFormIsOpen = (SysCmd(acSysCmdGetObjectState, acForm, "Rates") And
acObjStateOpen) <> False
End Function