|
 |
access thread: Code
Message #1 by "KennethMungwira" <KennethMungwira@Y...> on Fri, 19 Oct 2001 15:25:11
|
|
The following code seems to return the message:
*The Object may be a control on a read only Form
*The Object may be on a form that is open in Design view
*The value may be too large for this field
Below the code:
Private Sub cmdEditUndo_Click()
On Error GoTo Err_cmdEditUndo_Click
Dim ctl As Control
With cmdEditUndo
If .Caption = "Change This Record" Then
' Change the font color and caption
' of the cmdEditUndo button
.Caption = "Undo All Changes"
.ForeColor = vbRed
' Change the caption of the form Headers
lblHeader1.Caption = "Edit this IA Record"
lblHeader2.Caption = "Edit this IA Record"
' Allow editing of the main and sub forms
Call FormPermits(True)
' Copy the data from each combobox's and textbox's
' Control Source property to each control's
' tag property
For Each ctl In Me.Controls
Select Case ctl.ControlType
Case acComboBox, acTextBox
If Not IsNull(ctl) Then
ctl.Tag = ctl
End If
End Select
Next ctl
' Do the same for the subform's fields
For Each ctl In Me!subVoltConn.Form
Select Case ctl.ControlType
Case acComboBox, acTextBox
If Not IsNull(ctl) Then
ctl.Tag = ctl
End If
End Select
Next ctl
For Each ctl In Me!subCODate.Form
Select Case ctl.ControlType
Case acComboBox, acTextBox
If Not IsNull(ctl) Then
ctl.Tag = ctl
End If
End Select
Next ctl
For Each ctl In Me!ICsubStatusInfo.Form
Select Case ctl.ControlType
Case acComboBox, acTextBox
If Not IsNull(ctl) Then
ctl.Tag = ctl
End If
End Select
Next ctl
Else
' Change the font color and caption
' of the cmdEditUndo button
.Caption = "Change This Record"
.ForeColor = vbBlue
' Change the caption of the form Headers
lblHeader1.Caption = "View IA Request Data Only"
lblHeader2.Caption = "View IA Request Data Only"
' Do not allow editing of the main and sub forms
' Undo any changes by copying the data from
' the control's Tag property to the control's
' Control Source property
For Each ctl In Me.Controls
Select Case ctl.ControlType
Case acComboBox, acTextBox
If Len(ctl.Tag) > 0 And ctl.Name <> "CommonID" Then
ctl = ctl.Tag
End If
End Select
Next ctl
' Do the same for the subform's fields
For Each ctl In Me!subVoltConn.Form
Select Case ctl.ControlType
Case acComboBox, acTextBox
If Len(ctl.Tag) > 0 Then
ctl = ctl.Tag
End If
End Select
Next ctl
For Each ctl In Me!subCODate.Form
Select Case ctl.ControlType
Case acComboBox, acTextBox
If Len(ctl.Tag) > 0 Then
ctl = ctl.Tag
End If
End Select
Next ctl
For Each ctl In Me!ICsubStatusInfo.Form
Select Case ctl.ControlType
Case acComboBox, acTextBox
If Len(ctl.Tag) > 0 Then
ctl = ctl.Tag
End If
End Select
Next ctl
Call cmdSave_Click
End If
End With
Exit_cmdEditUndo_Click:
Exit Sub
Err_cmdEditUndo_Click:
MsgBox Err.Description
Resume Exit_cmdEditUndo_Click
End Sub
Please help?
Message #2 by "KennethMungwira" <KennethMungwira@Y...> on Fri, 19 Oct 2001 15:34:06
|
|
This code is runnning behind a subform and when the cmdEditUndo button is
hit I run into problems:
Can anyone help me.
Option Compare Database
Option Explicit
Private Sub cmbStatus_Change()
If Not (IsNull(Me.txtEntry) Or IsNull(Me.txtDaysToComplete)) Then
Me.txtDue = DateAdd("d", Me.txtDaysToComplete.Value, Me.txtEntry)
Else
Me.txtDue = Null
End If
End Sub
Private Sub txtEntry_Exit(Cancel As Integer)
If Not (IsNull(Me.txtEntry) Or IsNull(Me.txtDaysToComplete) Or IsNull)
Then
Me.txtDue = DateAdd("d", Me.txtDaysToComplete.Value, Me.txtEntry)
Else
Me.txtDue = Null
End If
End Sub
Message #3 by "Pardee, Roy E" <roy.e.pardee@l...> on Fri, 19 Oct 2001 07:55:17 -0700
|
|
Which line is causing the error?
If you need Undo functionality, you might try just calling the Undo method
of the form itself, e.g.:
Me.Undo
You shouldn't need to explicitly save off the values of each record if you
do that--Access keeps track of them for you. Or am I just not understanding
something?
HTH,
-Roy
Roy Pardee
Programmer/Analyst
SWFPAC Lockheed Martin IT
(xxx) xxx-xxxx
-----Original Message-----
From: KennethMungwira [mailto:KennethMungwira@y...]
Sent: Friday, October 19, 2001 8:24 AM
To: Access
Subject: [access] Code
The following code seems to return the message:
*The Object may be a control on a read only Form
*The Object may be on a form that is open in Design view
*The value may be too large for this field
Below the code:
Private Sub cmdEditUndo_Click()
On Error GoTo Err_cmdEditUndo_Click
Dim ctl As Control
With cmdEditUndo
If .Caption = "Change This Record" Then
' Change the font color and caption
' of the cmdEditUndo button
.Caption = "Undo All Changes"
.ForeColor = vbRed
' Change the caption of the form Headers
lblHeader1.Caption = "Edit this IA Record"
lblHeader2.Caption = "Edit this IA Record"
' Allow editing of the main and sub forms
Call FormPermits(True)
' Copy the data from each combobox's and textbox's
' Control Source property to each control's
' tag property
For Each ctl In Me.Controls
Select Case ctl.ControlType
Case acComboBox, acTextBox
If Not IsNull(ctl) Then
ctl.Tag = ctl
End If
End Select
Next ctl
' Do the same for the subform's fields
For Each ctl In Me!subVoltConn.Form
Select Case ctl.ControlType
Case acComboBox, acTextBox
If Not IsNull(ctl) Then
ctl.Tag = ctl
End If
End Select
Next ctl
For Each ctl In Me!subCODate.Form
Select Case ctl.ControlType
Case acComboBox, acTextBox
If Not IsNull(ctl) Then
ctl.Tag = ctl
End If
End Select
Next ctl
For Each ctl In Me!ICsubStatusInfo.Form
Select Case ctl.ControlType
Case acComboBox, acTextBox
If Not IsNull(ctl) Then
ctl.Tag = ctl
End If
End Select
Next ctl
Else
' Change the font color and caption
' of the cmdEditUndo button
.Caption = "Change This Record"
.ForeColor = vbBlue
' Change the caption of the form Headers
lblHeader1.Caption = "View IA Request Data Only"
lblHeader2.Caption = "View IA Request Data Only"
' Do not allow editing of the main and sub forms
' Undo any changes by copying the data from
' the control's Tag property to the control's
' Control Source property
For Each ctl In Me.Controls
Select Case ctl.ControlType
Case acComboBox, acTextBox
If Len(ctl.Tag) > 0 And ctl.Name <> "CommonID" Then
ctl = ctl.Tag
End If
End Select
Next ctl
' Do the same for the subform's fields
For Each ctl In Me!subVoltConn.Form
Select Case ctl.ControlType
Case acComboBox, acTextBox
If Len(ctl.Tag) > 0 Then
ctl = ctl.Tag
End If
End Select
Next ctl
For Each ctl In Me!subCODate.Form
Select Case ctl.ControlType
Case acComboBox, acTextBox
If Len(ctl.Tag) > 0 Then
ctl = ctl.Tag
End If
End Select
Next ctl
For Each ctl In Me!ICsubStatusInfo.Form
Select Case ctl.ControlType
Case acComboBox, acTextBox
If Len(ctl.Tag) > 0 Then
ctl = ctl.Tag
End If
End Select
Next ctl
Call cmdSave_Click
End If
End With
Exit_cmdEditUndo_Click:
Exit Sub
Err_cmdEditUndo_Click:
MsgBox Err.Description
Resume Exit_cmdEditUndo_Click
End Sub
|
|
 |