473,407 Members | 2,598 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Displaying Subform

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
2 1914
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Matt K. | last post by:
Hi there, I have a form in an Access project that contains a subform which displays the results of a query of the style "select * from where = #a certain date#". In the main part of the form...
3
by: Robin S. | last post by:
I tried to ask this question several days ago, but I didn't explain my application correctly. Basically I want to have one record from table "A" and I want to display, say, 5 records from table...
13
by: Aladdin | last post by:
I have an MS Access form on which I have a listbox listing tables in that database. I want to be able to click on any of those tables and view its contents on the same form using subforms or any...
5
by: Robert | last post by:
Hello Accessors I have some reports created in Access that are very good for what they do. However, it seems to me that when you are displaying information you don't need to print out that a...
5
by: tdmailbox | last post by:
I have a form with a child form. In the child form there is a list of names that can grow quite large. On the parent form I want to display the first name from the child form. I set up a test...
1
by: Shiva | last post by:
Hi, My (main)form has a subform that contains the details of the mainform. The default view of the mainform is 'single form', the default view of the subform containing the details is...
2
by: Susan Bricker | last post by:
Greetings! Still the same application (as previous posts). I worked on the app while at work (don't tell my boss ... cause this is just for fun and not work related) and the form was working,...
4
by: Krzysztof Bartosiewicz | last post by:
Hi! I haven't been using Access for a very long time and I forgot everything :) I will be very greatful for help since I have been fighting with this problem for a few hours... I have three...
3
by: Typehigh | last post by:
I am a good programmer, but this one stumps me! I have a form with a continuous subform. The continuous subform contains records of data and may reach a depth of 1000's of entities. I have...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.