toggle link disabled

  • Thread starter zizi2007 via AccessMonster.com
  • Start date
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
 
J

Jeanette Cunningham

zizi,
you can change the allow edits to yes for the short time that the toggle
buttons have the focus.
Once the focus moves off the toggle buttons, set allow edits to false.
When the toggle buttons get the focus, set allow edits to true.


Jeanette Cunningham -- Melbourne Victoria Australia


zizi2007 via AccessMonster.com said:
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
 
Z

zizi2007 via AccessMonster.com

could you be more specific about where to put that?

thanks.
 
Z

zizi2007 via AccessMonster.com

Never mind... I figured it out!! I just got to work, so I was not thinking
clearly yet!

thanks for your help. have a good weekend down under!

Zizi2007
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top