M
mark r
Please read through some of my VB code below, to get an
idea of some of the functionality invovled with
my "scenario".
The whole "issue" began when I got an error message:
along the lines of "the database engine expects .ADDNEW
or .EDIT when Update or Cancel event is used."
When I did not include the .edit aspect of
the code in the sub routine, I got that error message.
I don't get an error now that I included this
rs=recordset and .Edit piece of code. But I am not
sure of what I am really doing and not sure if I am doing
something to my tables that I don't really want.
What I want is for certain critical fields on the form to
have a red backcolor if the field ISNULL, otherwise
white. So I am not sure why I need a .EDIT or .ADDNEW
method since I am not changing table values.
I am having my LOOKUPCOMBOBUTTON_AFTERUPDATE function
check the backcolors after it does eveerything else it
does so that the colors are all correct once I move
forward to a different record. That is part of the reason
I was getting that error. But this combobutton has
a .EDIT method. And I put the .EDIT into the called
subroutine to eliminate the error.
You can see I have only enough knowledge to be dangerous.
Can you clear the fog for me?
Sub NEWSCREENCHANGECTLCOLOR()
For Each ctl In Me.Controls
Dim rs As DAO.Recordset
Set rs = Me.RecordsetClone
With rs
If ctl.Tag = "Checkred" Then
If IsNull(ctl.Value) Then
ctl.BackColor = vbRed
Else
ctl.BackColor = vbWhite
End If
End If
.Edit
'.Close
'Me.Bookmark = .Bookmark
End With
'rs.Close
Next ctl
End Sub
Function Chkcolor()
' critical fields are red background; this fnc changes
them to white once no longer NULL
With Me.ActiveControl
If IsNull(.Value) Then
.BackColor = vbRed
Else
.BackColor = vbWhite
End If
End With
End Function
Private Sub commnewscrn_Click()
On Error GoTo Err_commnewscrn_Click
For Each ctl In Me.Controls
Dim rs As DAO.Recordset
Set rs = Me.RecordsetClone
With rs
if ctl.Tag = "Checkred" Then
If IsNull(ctl.Value) Then
ctl.BackColor = vbRed
Else
ctl.BackColor = vbWhite
End If
End If
.Edit
'.Close
'Me.Bookmark = .Bookmark
End With
'rs.Close
Next ctl
Exit_commnewscrn_Click:
Exit Sub
Err_commnewscrn_Click:
MsgBox Err.description
Resume Exit_commnewscrn_Click
End Sub
Private Sub combo39_AfterUpdate()
Rem Go TO Select records ONLY PATIENTS THAT Presented
Today
Rem Order: order presented in clinic today
Dim rs As DAO.Recordset
Set rs = Me.RecordsetClone
With rs
.FindFirst "ID = " & Me.Combo39
.Edit 'Mode
!combodate = Date
.Update
Me.Bookmark = .Bookmark
End With
Me.Combo39.Requery
Me.Combo43.Requery
Me.List_todaysrecs.Requery
Me.List_HX_all.Requery
Me.Combo47.Requery
Call NEWSCREENCHANGECTLCOLOR
Rem Me.Comboselectdate.Requery
End Sub
..
idea of some of the functionality invovled with
my "scenario".
The whole "issue" began when I got an error message:
along the lines of "the database engine expects .ADDNEW
or .EDIT when Update or Cancel event is used."
When I did not include the .edit aspect of
the code in the sub routine, I got that error message.
I don't get an error now that I included this
rs=recordset and .Edit piece of code. But I am not
sure of what I am really doing and not sure if I am doing
something to my tables that I don't really want.
What I want is for certain critical fields on the form to
have a red backcolor if the field ISNULL, otherwise
white. So I am not sure why I need a .EDIT or .ADDNEW
method since I am not changing table values.
I am having my LOOKUPCOMBOBUTTON_AFTERUPDATE function
check the backcolors after it does eveerything else it
does so that the colors are all correct once I move
forward to a different record. That is part of the reason
I was getting that error. But this combobutton has
a .EDIT method. And I put the .EDIT into the called
subroutine to eliminate the error.
You can see I have only enough knowledge to be dangerous.
Can you clear the fog for me?
Sub NEWSCREENCHANGECTLCOLOR()
For Each ctl In Me.Controls
Dim rs As DAO.Recordset
Set rs = Me.RecordsetClone
With rs
If ctl.Tag = "Checkred" Then
If IsNull(ctl.Value) Then
ctl.BackColor = vbRed
Else
ctl.BackColor = vbWhite
End If
End If
.Edit
'.Close
'Me.Bookmark = .Bookmark
End With
'rs.Close
Next ctl
End Sub
Function Chkcolor()
' critical fields are red background; this fnc changes
them to white once no longer NULL
With Me.ActiveControl
If IsNull(.Value) Then
.BackColor = vbRed
Else
.BackColor = vbWhite
End If
End With
End Function
Private Sub commnewscrn_Click()
On Error GoTo Err_commnewscrn_Click
For Each ctl In Me.Controls
Dim rs As DAO.Recordset
Set rs = Me.RecordsetClone
With rs
if ctl.Tag = "Checkred" Then
If IsNull(ctl.Value) Then
ctl.BackColor = vbRed
Else
ctl.BackColor = vbWhite
End If
End If
.Edit
'.Close
'Me.Bookmark = .Bookmark
End With
'rs.Close
Next ctl
Exit_commnewscrn_Click:
Exit Sub
Err_commnewscrn_Click:
MsgBox Err.description
Resume Exit_commnewscrn_Click
End Sub
Private Sub combo39_AfterUpdate()
Rem Go TO Select records ONLY PATIENTS THAT Presented
Today
Rem Order: order presented in clinic today
Dim rs As DAO.Recordset
Set rs = Me.RecordsetClone
With rs
.FindFirst "ID = " & Me.Combo39
.Edit 'Mode
!combodate = Date
.Update
Me.Bookmark = .Bookmark
End With
Me.Combo39.Requery
Me.Combo43.Requery
Me.List_todaysrecs.Requery
Me.List_HX_all.Requery
Me.Combo47.Requery
Call NEWSCREENCHANGECTLCOLOR
Rem Me.Comboselectdate.Requery
End Sub
..