Data Entry property keeps setting to False

D

DeDBlanK

Hello and thanks in advance.
I have searched for this issue and I have came up empty handed.
I have a form with some subforms.
On the main form there are two sets of subforms: One Data Entry, One
Data Edit
On the main form there is an Approval box that sets the Enabled
properties of the subforms to False when the Approval box has be
checked (through vba)
The issue is that when the Data Entry subforms are Enabled = False, it
seems to also turn the Data Entry property to False also.
example: Me.frm02Machine.Form!frm03ProductionAdd.Enabled = False
When the Approval box is unchecked and the subforms Enabled properties
are set back to True, the subform Data Entry property is still stuck
to False. This allows records into the Add Subform when they are not
suppose to be there. If I open the subform, by itself, the DataEntry
Property is True. If I close the main form and reopen it, the
DataEntry Property on the subform is True.
I assume this is probably caused by the Access way handles code
proceedures and I am most likely doing something incorrectly, or do I
need to add something in the VBA to tell it to set the DataEntry
properties to True again?
Confused,
DeDBlanK
 
D

DeDBlanK

Hello and thanks in advance.
I have searched for this issue and I have came up empty handed.
I have a form with some subforms.
On the main form there are two sets of subforms:  One Data Entry, One
Data Edit
On the main form there is an Approval box that sets the Enabled
properties of the subforms to False when the Approval box has be
checked (through vba)
The issue is that when the Data Entry subforms are Enabled = False, it
seems to also turn the Data Entry property to False also.
example:  Me.frm02Machine.Form!frm03ProductionAdd.Enabled = False
When the Approval box is unchecked and the subforms Enabled properties
are set back to True, the subform Data Entry property is still stuck
to False.  This allows records into the Add Subform when they are not
suppose to be there.  If I open the subform, by itself, the DataEntry
Property is True.  If I close the main form and reopen it, the
DataEntry Property on the subform is True.
I assume this is probably caused by the Access way handles code
proceedures and I am most likely doing something incorrectly, or do I
need to add something in the VBA to tell it to set the DataEntry
properties to True again?
Confused,
DeDBlanK

OK, finally found some information. I think it may be the way I am
opening the main form. When it opens it opens with
DoCmd.openform,,acformedit, rs!pkReport
This is a filter based on another form to open the report.
So....I need to know if opening a main form as an edit effect the
subforms?
If so, what can I do to change the property of the add form to
DataEntry?
I have ran in the Immediate window the formname with .DataEntry and
get:
RTerror 438, Object doesn't support this property or method.
The subform is saved with the dataentry property set to 'Yes', so I am
not clear on what to do.?.?.?
 
B

Banana

Omit the argument 'acFormEdit', if my memory serves. It's optional
anyway and has unintended effects that may interfere with your other
settings such as Data Entry and AllowXXX properties.
 
D

DeDBlanK

Omit the argument 'acFormEdit', if my memory serves. It's optional
anyway and has unintended effects that may interfere with your other
settings such as Data Entry and AllowXXX properties.





- Show quoted text -

Thanks for the help.
However, No dice. =( I tried it that way. Same effect either way.
It must then have something to do with Enabled properties.
I have code in place that when the checkbox control is true, it sets
the subform Enabled property to False and vise versa.
When the subform Enabled property is set back to True, the subform
DataEntry property somehow goes to False when it should be true. I
don't understand why. I would set the DataEntry property through
code, but I get the RTError of 438.
 
B

Banana

DeDBlanK said:
Thanks for the help.
However, No dice. =( I tried it that way. Same effect either way.
It must then have something to do with Enabled properties.
I have code in place that when the checkbox control is true, it sets
the subform Enabled property to False and vise versa.
When the subform Enabled property is set back to True, the subform
DataEntry property somehow goes to False when it should be true. I
don't understand why. I would set the DataEntry property through
code, but I get the RTError of 438.

Maybe posting the code behind that control may help us get a picture.
Also, I'm not clear if you already have had code on the (sub) form's
open/load/current event to set the property accordingly.

WRT the error, I believe that this is because Data Entry is one of
properties that can be only set in design view or something similar to
that. Makes sense, really, as the forms behaves very differently in a
data entry mode compared to the usual mode and switching between would
raise lot of hackles, I imagine. You probably could get away with it by
doing something like:

<pseudocode>
Application.Echo False
Me.MySubform.SourceObject = ""
DoCmd.OpenForm "MySubform", acDesign, acHidden
Forms("MySubform").DataEntry = XXX
DoCmd.Save '<== Risky as it may save other objects and you may not want
that! See if you can get a specific object name instead; check VBA help
DoCmd.Close acForm "MySubform"
Me.MySubform.SourceObject = "MySubform"
Application.Echo True
<pseudocode>

Note: You also should check the VBA file on 'Data Entry property'; it
may have something to say about changing the property at runtime.
 
D

DeDBlanK

Maybe posting the code behind that control may help us get a picture.
Also, I'm not clear if you already have had code on the (sub) form's
open/load/current event to set the property accordingly.

WRT the error, I believe that this is because Data Entry is one of
properties that can be only set in design view or something similar to
that. Makes sense, really, as the forms behaves very differently in a
data entry mode compared to the usual mode and switching between would
raise lot of hackles, I imagine. You probably could get away with it by
doing something like:

<pseudocode>
Application.Echo False
Me.MySubform.SourceObject = ""
DoCmd.OpenForm "MySubform", acDesign, acHidden
Forms("MySubform").DataEntry = XXX
DoCmd.Save '<== Risky as it may save other objects and you may not want
that! See if you can get a specific object name instead; check VBA help
DoCmd.Close acForm "MySubform"
Me.MySubform.SourceObject = "MySubform"
Application.Echo True
<pseudocode>

Note: You also should check the VBA file on 'Data Entry property'; it
may have something to say about changing the property at runtime.

Thanks for the help again and the quick response.
Form procedure:
user gets prompt from frm01ReportEdit. This form has 2 criteria that
must be filed.
(this opens the main form (frm01ReportEdit)
***********CODE START frm01ReportEdit*********
Private Sub cmdFindAdd_Click()
'requires a reference set for Microsoft DAO 3.x Object Library
On Error GoTo HandleError
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
Dim strForm As String
Dim strDialog As String
Dim strLine As String
Dim strShift As String
Dim intAnswer As Integer
Dim Response As Integer

'all three criteria required
'If any criteria is missing, say so and exit Sub
If Nz(Me.cmbDate, "") = "" Or Nz(Me.cmbShift, "") = "" Then
MsgBox "Missing Date, Shift, or Area! Please enter all
criteria before clicking find.", vbOKOnly, "Oops!"
Exit Sub
Else
Set db = CurrentDb()

'create SQL
strSQL = "SELECT pkReport FROM tbl100Report"
strSQL = strSQL & " WHERE [dtmDate] = #" & [Forms]!
[frm01ReportEdit]![cmbDate] & "# "
strSQL = strSQL & " AND [strShift] = '" & [Forms]!
[frm01ReportEdit]![cmbShift] & "' ;"

' open recordset

Set rs = db.OpenRecordset(strSQL)

'check for records
If rs.BOF And rs.EOF Then
'Send msgbox to ask wether to enter data or if entry was a
mistake
intAnswer = MsgBox("There is no current entry for " &
vbCrLf & Chr(34) & Me.cmbDate & _
" " & Me.cmbShift & _
" Shift " & _
" " & Chr(34) & "." & vbCrLf & _
"Would you like to add it to now?"
_
, vbQuestion + vbYesNo, "No Report
Found?")
Select Case intAnswer
Case vbYes
'set cursor to hourglass
DoCmd.Hourglass (True)
'open form in add mode
DoCmd.OpenForm "frm01Report",
acNormal, , , acFormAdd, acWindowNormal

'set lookups for criteria to input to form
Forms!frm01Report.dtmDate.Value =
Me.cmbDate
Forms!frm01Report.cmbShift.Value =
Me.cmbShift

DoCmd.Hourglass (False)

strDialog = "frm01ReportEdit"
DoCmd.Close acForm, strDialog, acSaveNo
Exit Sub
Case vbNo
'Tell user to try again, resume
MsgBox "Please try again." _
, vbInformation, "Data Entry"

Exit Sub
End Select

Else
'set cursor to hourglass
DoCmd.Hourglass (True)
rs.MoveLast
rs.MoveFirst

'***************Filter CODE******************
DoCmd.OpenForm "frm01Report", acNormal, , "[pkReport] = "
& rs!pkReport
DoCmd.Hourglass (False)
End If
End If

HandleError_Exit:
On Error Resume Next

Exit_cmdFindAdd_Click:
'clean up
rs.Close
Set rs = Nothing
Set db = Nothing
strDialog = "frm01ReportEdit"
DoCmd.Close acForm, strDialog, acSaveNo

Exit Sub


HandleError:
MsgBox Err.Number & " - " & Err.Description
Resume HandleError_Exit
End Sub
***********CODE END frm01ReportEdit*********

Description of frm01Report:
frm01Report has three subforms frm02Machine, frm06MaintenanceAdd
(dataentry), frm06MaintenanceEdit
frm02Machine has 6 subforms in it: to keep from typing all that
look in the code
On the frm01Report there is a button cmdApproval
This button set True and False to a ysn field which is disabled.
When the button is clicked, prompt for password, if match, set ysn to
true, disable subforms except frm02Machine which needs to be left
alone because the user can still look at it, but not change the data.
I don't know if locking the fields would be any different.
anyway, here's the code for the cmdApproval button:
***********CODE START frm01ReportEdit cmdApproval*********
Private Sub cmdApprove_Click()
On Error GoTo Err_cmdApprove_Click

Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
Dim strUser As String
Dim strInput As String
Dim strMsg As String

Set db = CurrentDb()

strUser = Environ("username") 'NT LoginID

'set SQL to query USER password from Windows USER name
strSQL = "SELECT Password FROM tblADMINpassword WHERE Login = '" &
strUser _
& "' AND ysnActive = -1 AND password <> null AND
ysnApprove = -1;"

'set recordset from the SQL
Set rs = db.OpenRecordset(strSQL)

If rs.BOF And rs.EOF Then
Beep
'if no psw exisits
MsgBox "You have no password or" & vbCr & "not allowed to
approve reports", vbCritical, "Error"
'exit the routine
Exit Sub
Else
If Me.ysnLocked = 0 Then
strMsg = "Do you want to lock and approve the Report?" &
vbCrLf & vbLf & "Please enter your Password."
strInput = InputBoxDK(Prompt:=strMsg, Title:="Lock and
Approve Report")

If strInput = rs!Password Then
Me.frm02Machine.Form!txtPress.SetFocus
Me.strApproved = strUser
Me.dtmApprovedOn = Now()
Me.ysnLocked = -1
Me.frm02Machine.Form!fkPress.Enabled = False
Me.frm02Machine.Form!cmdAdd.Enabled = False
Me.frm02Machine.Form!intLunch.Enabled = False
Me.frm02Machine.Form!intBreaks.Enabled = False
Me.frm02Machine.Form!intPlannedDT.Enabled = False
Me.frm02Machine.Form!frm03ProductionAdd.Enabled =
False
Me.frm02Machine.Form!frm03ProductionEdit.Enabled =
False
Me.frm02Machine.Form!frm04Downtime.Enabled = False
Me.frm02Machine.Form!frm04DowntimeEdit.Enabled = False
Me.frm02Machine.Form![Scrap Entry].Enabled = False
Me.frm02Machine.Form![Scrap Edit].Enabled = False
Me.MachineAdded.Enabled = False
Me.cmdApprove.Caption = "UnApprove Report"
Beep
MsgBox "The Report has been Approved." & vbCrLf & vbLf
& "The report is now Locked.", _
vbInformation, "Report Condition"
ElseIf strInput = "" Then
Exit Sub
Else
Beep
MsgBox "Incorrect Password!" & vbCrLf & vbLf & "Report
Not Approved or Locked." _
& vbCrLf & vbLf & "Failed attemp has been
logged!", vbCritical, "Invalid Password"
Exit Sub
End If
Else
strMsg = "Do you want to unapprove the Report?" & vbCrLf &
vbLf & "Please enter your Password to edit."
strInput = InputBoxDK(Prompt:=strMsg, Title:="UnLock and
UnApprove Report")
If strInput = rs!Password Then
Me.strApproved = ""
Me.dtmApprovedOn = ""
Me.ysnLocked = 0
Me.frm02Machine.Form!fkPress.Enabled = True
Me.frm02Machine.Form!cmdAdd.Enabled = True
Me.frm02Machine.Form!intLunch.Enabled = True
Me.frm02Machine.Form!intBreaks.Enabled = True
Me.frm02Machine.Form!intPlannedDT.Enabled = True
Me.frm02Machine.Form!frm03ProductionAdd.Enabled =
True
Me.frm02Machine.Form!frm03ProductionEdit.Enabled =
True
Me.frm02Machine.Form!frm04Downtime.Enabled = True
Me.frm02Machine.Form!frm04DowntimeEdit.Enabled =
True
Me.frm02Machine.Form![Scrap Entry].Enabled = True
Me.frm02Machine.Form![Scrap Edit].Enabled = True
Me.MachineAdded.Enabled = True
Me.cmdApprove.Caption = "Approve Report"
MsgBox "Correct Password!" & vbCrLf & vbLf &
"Report unlocked for Editing." _
& vbCrLf & vbLf & "Approval has been
Removed.", vbInformation, "Unlock Successful"
Exit Sub
ElseIf strInput = "" Then
Exit Sub
Else
Beep
MsgBox "Incorrect Password!" & vbCrLf & vbLf & "Report
Not Unapproved or unLocked." _
& vbCrLf & vbLf & "Failed attemp has been
logged!", vbCritical, "Invalid Password"
Exit Sub
End If
End If
End If

Exit_cmdApprove_Click:
rs.Close
Set rs = Nothing
Set db = Nothing
Exit Sub

Err_cmdApprove_Click:
MsgBox "Runtime Error # " & Err.Number & vbCrLf & vbLf &
Err.Description
Resume Exit_cmdApprove_Click
End Sub
***********CODE END frm01ReportEdit cmdApproval*********
 
D

DeDBlanK

Maybe posting the code behind that control may help us get a picture.
Also, I'm not clear if you already have had code on the (sub) form's
open/load/current event to set the property accordingly.
WRT the error, I believe that this is because Data Entry is one of
properties that can be only set in design view or something similar to
that. Makes sense, really, as the forms behaves very differently in a
data entry mode compared to the usual mode and switching between would
raise lot of hackles, I imagine. You probably could get away with it by
doing something like:
<pseudocode>
Application.Echo False
Me.MySubform.SourceObject = ""
DoCmd.OpenForm "MySubform", acDesign, acHidden
Forms("MySubform").DataEntry = XXX
DoCmd.Save '<== Risky as it may save other objects and you may not want
that! See if you can get a specific object name instead; check VBA help
DoCmd.Close acForm "MySubform"
Me.MySubform.SourceObject = "MySubform"
Application.Echo True
<pseudocode>
Note: You also should check the VBA file on 'Data Entry property'; it
may have something to say about changing the property at runtime.

Thanks for the help again and the quick response.
Form procedure:
user gets prompt from frm01ReportEdit.  This form has 2 criteria that
must be filed.
(this opens the main form (frm01ReportEdit)
***********CODE START frm01ReportEdit*********
Private Sub cmdFindAdd_Click()
'requires a reference set for Microsoft DAO 3.x Object Library
   On Error GoTo HandleError
    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Dim strSQL As String
    Dim strForm As String
    Dim strDialog As String
    Dim strLine As String
    Dim strShift As String
    Dim intAnswer As Integer
    Dim Response As Integer

    'all three criteria required
    'If any criteria is missing, say so and exit Sub
    If Nz(Me.cmbDate, "") = "" Or Nz(Me.cmbShift, "") = "" Then
        MsgBox "Missing Date, Shift, or Area! Please enter all
criteria before clicking find.", vbOKOnly, "Oops!"
      Exit Sub
   Else
      Set db = CurrentDb()

      'create SQL
      strSQL = "SELECT pkReport FROM tbl100Report"
      strSQL = strSQL & " WHERE [dtmDate] = #" & [Forms]!
[frm01ReportEdit]![cmbDate] & "# "
      strSQL = strSQL & " AND [strShift] = '" & [Forms]!
[frm01ReportEdit]![cmbShift] & "' ;"

      ' open recordset

      Set rs = db.OpenRecordset(strSQL)

      'check for records
      If rs.BOF And rs.EOF Then
         'Send msgbox to ask wether to enter data or if entry was a
mistake
                 intAnswer = MsgBox("There is no current entry for " &
vbCrLf & Chr(34) & Me.cmbDate & _
                                    "" & Me.cmbShift & _
                                    "Shift " & _
                                    "" & Chr(34) & "." & vbCrLf & _
                                    "Would you like to add it to now?"
_
                                    ,vbQuestion + vbYesNo, "No Report
Found?")
            Select Case intAnswer
                    Case vbYes
                            'set cursor to hourglass
                            DoCmd.Hourglass (True)
                            'open form in addmode
                            DoCmd.OpenForm "frm01Report",
acNormal, , , acFormAdd, acWindowNormal

                            'set lookups for criteria to input to form
                            Forms!frm01Report..dtmDate.Value =
Me.cmbDate
                            Forms!frm01Report..cmbShift.Value =
Me.cmbShift

                            DoCmd.Hourglass (False)

                            strDialog = "frm01ReportEdit"
                            DoCmd.Close acForm, strDialog, acSaveNo
                            Exit Sub
                    Case vbNo
                            'Tell user to tryagain, resume
                            MsgBox "Please try again." _
                            , vbInformation, "Data Entry"

                            Exit Sub
                End Select

      Else
        'set cursor to hourglass
        DoCmd.Hourglass (True)
         rs.MoveLast
         rs.MoveFirst

            '***************Filter CODE******************
            DoCmd.OpenForm "frm01Report", acNormal, , "[pkReport] = "
& rs!pkReport
            DoCmd.Hourglass (False)
      End If
   End If

HandleError_Exit:
   On Error Resume Next

Exit_cmdFindAdd_Click:
   'clean up
   rs.Close
   Set rs = Nothing
   Set db = Nothing
    strDialog = "frm01ReportEdit"
    DoCmd.Close acForm, strDialog, acSaveNo

   Exit Sub

HandleError:
   MsgBox Err.Number & " - " & Err.Description
   Resume HandleError_Exit
End Sub
***********CODE END frm01ReportEdit*********

Description of frm01Report:
frm01Report has three subforms frm02Machine, frm06MaintenanceAdd
(dataentry), frm06MaintenanceEdit
     frm02Machine has 6 subforms in it: to keep from typing all that
look in the code
On the frm01Report there is a button cmdApproval
This button set True and False to a ysn field which is disabled.
When the button is clicked, prompt for password, if match, set ysn to
true, disable subforms except frm02Machine which needs to be left
alone because the user can still look at it, but not change the data.
I don't know if locking the fields would be any different.
anyway, here's the code for the cmdApproval button:
***********CODE START frm01ReportEdit cmdApproval*********
Private Sub cmdApprove_Click()
On Error GoTo Err_cmdApprove_Click

    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Dim strSQL As String
    Dim strUser As String
    Dim strInput As String
    Dim strMsg As String

    Set db = CurrentDb()

    strUser = Environ("username") 'NT LoginID

    'set SQL to query USER password from Windows USER name
    strSQL = "SELECT Password FROM tblADMINpassword WHERE Login ='" &
strUser _
                & "' AND ysnActive = -1 AND password <>null AND
ysnApprove = -1;"

    'set recordset from the SQL
    Set rs = db.OpenRecordset(strSQL)

    If rs.BOF And rs.EOF Then
        Beep
        'if no psw exisits
        MsgBox "You have no password or" & vbCr & "not allowed to
approve reports", vbCritical, "Error"
        'exit the routine
        Exit Sub
    Else
        If Me.ysnLocked = 0 Then
            strMsg = "Do you want to lock and approve the Report?" &
vbCrLf & vbLf & "Please enter your Password."
            strInput = InputBoxDK(Prompt:=strMsg, Title:="Lock and
Approve Report")

            If strInput = rs!Password Then
                Me.frm02Machine.Form!txtPress.SetFocus
                Me.strApproved = strUser
                Me.dtmApprovedOn = Now()
                Me.ysnLocked = -1
                Me.frm02Machine.Form!fkPress.Enabled = False
                Me.frm02Machine.Form!cmdAdd.Enabled = False
                Me.frm02Machine.Form!intLunch.Enabled =False
                Me.frm02Machine.Form!intBreaks.Enabled = False
                Me.frm02Machine.Form!intPlannedDT.Enabled= False
                Me.frm02Machine.Form!frm03ProductionAdd.Enabled =
False
                Me.frm02Machine.Form!frm03ProductionEdit.Enabled =
False
                Me.frm02Machine.Form!frm04Downtime.Enabled = False
                Me.frm02Machine.Form!frm04DowntimeEdit.Enabled = False
                Me.frm02Machine.Form![Scrap Entry].Enabled = False
                Me.frm02Machine.Form![Scrap Edit].Enabled= False
                Me.MachineAdded.Enabled = False
                Me.cmdApprove.Caption = "UnApprove Report"
                Beep
                MsgBox "The Report has been Approved." & vbCrLf & vbLf
& "The report is now Locked.", _
                    vbInformation, "Report Condition"
            ElseIf strInput = "" Then
                Exit Sub
            Else
                Beep
                MsgBox "Incorrect Password!" & vbCrLf & vbLf & "Report
Not Approved or Locked." _
                    & vbCrLf & vbLf & "Failed attemp has been
logged!", vbCritical, "Invalid Password"
                Exit Sub
            End If
        Else
            strMsg = "Do you want to unapprove the Report?"& vbCrLf &
vbLf & "Please enter your Password to edit."
            strInput = InputBoxDK(Prompt:=strMsg, Title:="UnLock and
UnApprove Report")
                If strInput = rs!Password Then
                    Me.strApproved = ""
                    Me.dtmApprovedOn = ""
                    Me.ysnLocked = 0
                    Me.frm02Machine.Form!fkPress.Enabled = True
                    Me.frm02Machine.Form!cmdAdd.Enabled = True
                    Me.frm02Machine.Form!intLunch.Enabled = True
                    Me.frm02Machine.Form!intBreaks.Enabled = True
                    Me.frm02Machine.Form!intPlannedDT..Enabled = True
                    Me.frm02Machine.Form!frm03ProductionAdd.Enabled =
True
                    Me.frm02Machine.Form!frm03ProductionEdit.Enabled =
True
                    Me.frm02Machine.Form!frm04Downtime.Enabled = True
                    Me.frm02Machine.Form!frm04DowntimeEdit.Enabled =
True
                    Me.frm02Machine.Form![Scrap Entry].Enabled = True
                    Me.frm02Machine.Form![Scrap Edit]..Enabled = True
                    Me.MachineAdded.Enabled = True
                    Me.cmdApprove.Caption = "Approve Report"
                    MsgBox "Correct Password!" & vbCrLf & vbLf &
"Report unlocked for Editing." _
...

read more »- Hide quoted text -

- Show quoted text -

Did my post not work?
 
D

DeDBlanK

Hello and thanks in advance.
I have searched for this issue and I have came up empty handed.
I have a form with some subforms.
On the main form there are two sets of subforms:  One Data Entry, One
Data Edit
On the main form there is an Approval box that sets the Enabled
properties of the subforms to False when the Approval box has be
checked (through vba)
The issue is that when the Data Entry subforms are Enabled = False, it
seems to also turn the Data Entry property to False also.
example:  Me.frm02Machine.Form!frm03ProductionAdd.Enabled = False
When the Approval box is unchecked and the subforms Enabled properties
are set back to True, the subform Data Entry property is still stuck
to False.  This allows records into the Add Subform when they are not
suppose to be there.  If I open the subform, by itself, the DataEntry
Property is True.  If I close the main form and reopen it, the
DataEntry Property on the subform is True.
I assume this is probably caused by the Access way handles code
proceedures and I am most likely doing something incorrectly, or do I
need to add something in the VBA to tell it to set the DataEntry
properties to True again?
Confused,
DeDBlanK

Another Finding.
I believe it has something to do with the code residing on the
subform forms!frm01Report!frm02Machine
******CODE START***************
Private Sub Form_Current()
Dim rsClone As Recordset
Set rsClone = Me.RecordsetClone
If Me.NewRecord = True Then
Me!cmdAdd.Enabled = True
Me!cmdNext.Enabled = False
Me.cmdPrevious.Enabled = True
'Me!cmdFirst.Enabled = True
'Me!cmdLast.Enabled = True
ElseIf rsClone.Bookmarkable = True Then
If Forms!frm01Report!ysnLocked = True Then
Me.cmdAdd.Enabled = False
Else
Me.cmdAdd.Enabled = True
End If
rsClone.Bookmark = Me.Bookmark
rsClone.MovePrevious
'cmdFirst.Enabled = Not (rsClone.BOF)
If Forms!frm01Report!ysnLocked = True Then
'Me.cmdPrevious.SetFocus
cmdPrevious.Enabled = Not (rsClone.BOF)
Else
cmdPrevious.Enabled = Not (rsClone.BOF)
End If
rsClone.MoveNext
rsClone.MoveNext
If Forms!frm01Report!ysnLocked = True Then
'Me.cmdNext.SetFocus
cmdNext.Enabled = Not (rsClone.EOF)
Else
cmdNext.Enabled = Not (rsClone.EOF)
End If
'cmdLast.Enabled = Not (rsClone.EOF)
rsClone.MovePrevious

End If
rsClone.Close
End Sub
*****CODE END*****
I believe I have eliminated everything down to this code. So why
would a bookmark change a forms property of DataEntry to False?
 
D

DeDBlanK

Another Finding.
I believe it has something  to do with the code residing on the
subform forms!frm01Report!frm02Machine
******CODE START***************
Private Sub Form_Current()
    Dim rsClone As Recordset
    Set rsClone = Me.RecordsetClone
    If Me.NewRecord = True Then
        Me!cmdAdd.Enabled = True
        Me!cmdNext.Enabled = False
        Me.cmdPrevious.Enabled = True
        'Me!cmdFirst.Enabled = True
        'Me!cmdLast.Enabled = True
    ElseIf rsClone.Bookmarkable = True Then
        If Forms!frm01Report!ysnLocked = True Then
            Me.cmdAdd.Enabled = False
        Else
            Me.cmdAdd.Enabled = True
        End If
        rsClone.Bookmark = Me.Bookmark
        rsClone.MovePrevious
        'cmdFirst.Enabled = Not (rsClone.BOF)
        If Forms!frm01Report!ysnLocked = True Then
            'Me.cmdPrevious.SetFocus
            cmdPrevious.Enabled = Not (rsClone.BOF)
        Else
            cmdPrevious.Enabled = Not (rsClone.BOF)
        End If
        rsClone.MoveNext
        rsClone.MoveNext
        If Forms!frm01Report!ysnLocked = True Then
            'Me.cmdNext.SetFocus
            cmdNext.Enabled = Not (rsClone.EOF)
        Else
            cmdNext.Enabled = Not (rsClone.EOF)
        End If
        'cmdLast.Enabled = Not (rsClone.EOF)
        rsClone.MovePrevious

    End If
    rsClone.Close
End Sub
*****CODE END*****
I believe I have eliminated everything down to this code.  So why
would a bookmark change a forms property of DataEntry to False?- Hide quoted text -

- Show quoted text -

So, I am stuck. I am going to reiterate the situation to hopefully
clarify it.
Forms 3 (same as 4 but DataEntry=Yes) and 4 (continuous form) resides
in Form 2 (single form) which resides in Form 1 (single form)
if form 2 controls (other than record navigation) and Form 3 are set
to Enabled = False, everything is okay until the Previous or Next
buttons are clicked with just run a docmd.gotorecord , , acnext or
previous. When either of those buttons are clicked, Form 3 loses it's
property of DataEntry = Yes. I do not want this to happen and when I
try to put the code in after the acNext or acPrevious (.DataEntry =
True) I get a RT Error of 438.
 
D

DeDBlanK

Maybe posting the code behind that control may help us get a picture.
Also, I'm not clear if you already have had code on the (sub) form's
open/load/current event to set the property accordingly.

WRT the error, I believe that this is because Data Entry is one of
properties that can be only set in design view or something similar to
that. Makes sense, really, as the forms behaves very differently in a
data entry mode compared to the usual mode and switching between would
raise lot of hackles, I imagine. You probably could get away with it by
doing something like:

<pseudocode>
Application.Echo False
Me.MySubform.SourceObject = ""
DoCmd.OpenForm "MySubform", acDesign, acHidden
Forms("MySubform").DataEntry = XXX
DoCmd.Save '<== Risky as it may save other objects and you may not want
that! See if you can get a specific object name instead; check VBA help
DoCmd.Close acForm "MySubform"
Me.MySubform.SourceObject = "MySubform"
Application.Echo True
<pseudocode>

Note: You also should check the VBA file on 'Data Entry property'; it
may have something to say about changing the property at runtime.

Banana,
I think I found where the issue is being caused from, but I still
don't know why it does it. When 'DoCmd.GoToRecord' is ran, it is
setting the DataEntry Form Property to False. When the set of forms
are closed and reopened, it reassumes the orig property of True for
DataEntry.
The Next and Previous button are on subform B. Subform C is the data
entry form nested in SubformB.
 
D

DeDBlanK

Banana,
I think I found where the issue is being caused from, but I still
don't know why it does it.  When 'DoCmd.GoToRecord' is ran, it is
setting the DataEntry Form Property to False.  When the set of forms
are closed and reopened, it reassumes the orig property of True for
DataEntry.
The Next and Previous button are on subform B.  Subform C is the data
entry form nested in SubformB.- Hide quoted text -

- Show quoted text -

Fixed!!! In case anyone was following this thread. I ended up
reassigning all of the subformC Master and Child fields. Some reason
that fixed it. Didn't change anything, but just reassigned them.
STRANGE!!!
 
D

DeDBlanK

Fixed!!!  In case anyone was following this thread.  I ended up
reassigning all of the subformC Master and Child fields.  Some reason
that fixed it.  Didn't change anything, but just reassigned them.
STRANGE!!!- Hide quoted text -

- Show quoted text -

Problems back. I did find a thread on this issue.
http://www.pcreview.co.uk/forums/thread-3849348.php
Seems that this is an Access bug. However, I didn't quite grasp the
solution in that thread. Exactly how would I run a query that would
return an empty recordset and still be able to input the data and
store it into the table?
 
M

Marshall Barton

DeDBlanK said:
Problems back. I did find a thread on this issue.
http://www.pcreview.co.uk/forums/thread-3849348.php
Seems that this is an Access bug. However, I didn't quite grasp the
solution in that thread. Exactly how would I run a query that would
return an empty recordset and still be able to input the data and
store it into the table?


I haven't investigated your problem, but if all you want is
to bind the form to an empty recordset, just set the form's
RecordSource to a query with a criteria that is never true.
At its simplest this can be just using WHERE False

However, as David Fenton posted a long time ago, this causes
a full table scan that will be slow for a large table. It's
orders of magnitude more efficient to use an impossible
condition on an indexed field. Though not 100% impossible,
I use a criteria of 0 for an autonumber primary key field,
 
D

DeDBlanK

I haven't investigated your problem, but if all you want is
to bind the form to an empty recordset, just set the form's
RecordSource to a query with a criteria that is never true.
At its simplest this can be just using WHERE False

However, as David Fenton posted a long time ago, this causes
a full table scan that will be slow for a large table.  It's
orders of magnitude more efficient to use an impossible
condition on an indexed field.  Though not 100% impossible,
I use a criteria of 0 for an autonumber primary key field,

Thanks Marsh, it worked. My brain's fried from trying to figure that
issue out. Almost started from scratch because of it.
 

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