By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,825 Members | 1,281 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,825 IT Pros & Developers. It's quick & easy.

Displaying Subform

P: n/a
I am having a hard time trying to figure out why my code is not
working properly. I step through the code and check the values when
adding the data to the table, but my Refresh or Requery is not
displaying on the subform. Any suggestions? Thanks for your
help!!!!!!!!!!

********************** Code *************************************

Private Sub cmdOK_Click()
On Error GoTo Err_Handler

If IsNull(Me!txtNote) Then
MsgBox "A blank note cannot be saved.", 16, "ERROR:No Note"
Me!txtNote.SetFocus
Exit Sub
End If

'DoCmd.RunSQL _
'"INSERT IN Notes (CaseSysID,UserSysID,DateCreate,Note)" _
'& " VALUES(" & Me!txtCaseSysID & "," & intUser _
'& ",#" & Format(Date, "m/d/yyyy") & "#,'" & Me!txtNote & "');"

Dim wrkCurrent As Workspace
Dim db As Database
Dim NoteTB As Recordset
Dim fInTrans As Boolean

fInTrans = False
Set wrkCurrent = DBEngine.Workspaces(0)
Set db = CurrentDb()
Set NoteTB = db.OpenRecordset("Notes")

wrkCurrent.BeginTrans
fInTrans = True

With NoteTB
.AddNew
!CaseSysID = Me!txtCaseSysID
!UserSysID = intUser
!DateCreate = Date
!Note = Me!txtNote
.Update
.Move 0, .LastModified
End With

'Debug.Print CaseSysID, UserSysID, DateCreate, Note

wrkCurrent.CommitTrans
fInTrans = False

'frmLoaded!frmEditR.Requery

'Forms!frmEditR!frmNotesSub.Controls!AuditNotes
frmLoaded.refresh
DoCmd.Close acForm, "frmNotesAdd"

frmLoaded.Page8.SetFocus

'If frmLoaded!childAudit.Visible = False Then
'frmLoaded!childAudit.Visible = True
'End If

'Me!DataEntry = True

Err_Handler:
If fInTrans Then
wrkCurrent.Rollback
MsgBox "Error occurred. Note has not been saved!", 16,
"ERROR"
End If
End Sub
Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On 30 Jun 2004 15:38:39 -0700, al*****@nmcourts.com (Debster) wrote:

Get rid of the transaction. It is not necessary for single inserts.
There are not multiple actions which you want to appear as atomic.

To requery the subform:
Me.<subformcontrol>.form.requery

-Tom.

I am having a hard time trying to figure out why my code is not
working properly. I step through the code and check the values when
adding the data to the table, but my Refresh or Requery is not
displaying on the subform. Any suggestions? Thanks for your
help!!!!!!!!!!

********************** Code *************************************

Private Sub cmdOK_Click()
On Error GoTo Err_Handler

If IsNull(Me!txtNote) Then
MsgBox "A blank note cannot be saved.", 16, "ERROR:No Note"
Me!txtNote.SetFocus
Exit Sub
End If

'DoCmd.RunSQL _
'"INSERT IN Notes (CaseSysID,UserSysID,DateCreate,Note)" _
'& " VALUES(" & Me!txtCaseSysID & "," & intUser _
'& ",#" & Format(Date, "m/d/yyyy") & "#,'" & Me!txtNote & "');"

Dim wrkCurrent As Workspace
Dim db As Database
Dim NoteTB As Recordset
Dim fInTrans As Boolean

fInTrans = False
Set wrkCurrent = DBEngine.Workspaces(0)
Set db = CurrentDb()
Set NoteTB = db.OpenRecordset("Notes")

wrkCurrent.BeginTrans
fInTrans = True

With NoteTB
.AddNew
!CaseSysID = Me!txtCaseSysID
!UserSysID = intUser
!DateCreate = Date
!Note = Me!txtNote
.Update
.Move 0, .LastModified
End With

'Debug.Print CaseSysID, UserSysID, DateCreate, Note

wrkCurrent.CommitTrans
fInTrans = False

'frmLoaded!frmEditR.Requery

'Forms!frmEditR!frmNotesSub.Controls!AuditNotes
frmLoaded.refresh
DoCmd.Close acForm, "frmNotesAdd"

frmLoaded.Page8.SetFocus

'If frmLoaded!childAudit.Visible = False Then
'frmLoaded!childAudit.Visible = True
'End If

'Me!DataEntry = True

Err_Handler:
If fInTrans Then
wrkCurrent.Rollback
MsgBox "Error occurred. Note has not been saved!", 16,
"ERROR"
End If
End Sub


Nov 13 '05 #2

P: n/a
Hi Tom,

Thank you for your response. When you say 'get rid of the
transaction', what part of the code are you talkin about? I also
tried the requery without any luck. Do you have any other suggestions
that I may try. Thanks again for your help!

Tom van Stiphout <no*************@cox.net> wrote in message news:<q3********************************@4ax.com>. ..
On 30 Jun 2004 15:38:39 -0700, al*****@nmcourts.com (Debster) wrote:

Get rid of the transaction. It is not necessary for single inserts.
There are not multiple actions which you want to appear as atomic.

To requery the subform:
Me.<subformcontrol>.form.requery

-Tom.

I am having a hard time trying to figure out why my code is not
working properly. I step through the code and check the values when
adding the data to the table, but my Refresh or Requery is not
displaying on the subform. Any suggestions? Thanks for your
help!!!!!!!!!!

********************** Code *************************************

Private Sub cmdOK_Click()
On Error GoTo Err_Handler

If IsNull(Me!txtNote) Then
MsgBox "A blank note cannot be saved.", 16, "ERROR:No Note"
Me!txtNote.SetFocus
Exit Sub
End If

'DoCmd.RunSQL _
'"INSERT IN Notes (CaseSysID,UserSysID,DateCreate,Note)" _
'& " VALUES(" & Me!txtCaseSysID & "," & intUser _
'& ",#" & Format(Date, "m/d/yyyy") & "#,'" & Me!txtNote & "');"

Dim wrkCurrent As Workspace
Dim db As Database
Dim NoteTB As Recordset
Dim fInTrans As Boolean

fInTrans = False
Set wrkCurrent = DBEngine.Workspaces(0)
Set db = CurrentDb()
Set NoteTB = db.OpenRecordset("Notes")

wrkCurrent.BeginTrans
fInTrans = True

With NoteTB
.AddNew
!CaseSysID = Me!txtCaseSysID
!UserSysID = intUser
!DateCreate = Date
!Note = Me!txtNote
.Update
.Move 0, .LastModified
End With

'Debug.Print CaseSysID, UserSysID, DateCreate, Note

wrkCurrent.CommitTrans
fInTrans = False

'frmLoaded!frmEditR.Requery

'Forms!frmEditR!frmNotesSub.Controls!AuditNotes
frmLoaded.refresh
DoCmd.Close acForm, "frmNotesAdd"

frmLoaded.Page8.SetFocus

'If frmLoaded!childAudit.Visible = False Then
'frmLoaded!childAudit.Visible = True
'End If

'Me!DataEntry = True

Err_Handler:
If fInTrans Then
wrkCurrent.Rollback
MsgBox "Error occurred. Note has not been saved!", 16,
"ERROR"
End If
End Sub

Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.