473,503 Members | 2,066 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Form Does Not Refresh

Hi,

I have a popup that is used to update the records on an open form. I
cannot get form to refresh with the new values. Any help you can lend
would be appreciated. Here is the code for the popup form:

'-----------------------------------------------
Sub AddRep_Click()

Dim db As Database
Dim rst1 As Recordset
Dim rst2 As Recordset

Set db = CurrentDb
Set rst1 = db.OpenRecordset("tblAccountProfile", dbOpenDynaset)

rst1.Edit
rst1!TrainerID = Me.txtID
rst1!TrainerName = Me.txtName
rst1!TrainerRepType = Me.txtRepType
rst1.Update
rst1.Requery

MsgBox "Sales Rep information has been updated.", vbOKOnly, "Sales Rep
Information"

DoCmd.Close acForm, "frmSalesRepPopUp", acSaveNo
DoCmd.RepaintObject acForm, "frmAccountProfile"
Forms!frmAccountProfile.Refresh

Set rst1 = Nothing
Set db = Nothing

End Sub
'----------------------------

Thank you.

Henry

Mar 7 '06 #1
6 8518
Henry Stockbridge wrote:
Hi,

I have a popup that is used to update the records on an open form. I
cannot get form to refresh with the new values. Any help you can lend
would be appreciated. Here is the code for the popup form:

'-----------------------------------------------
Sub AddRep_Click()

Dim db As Database
Dim rst1 As Recordset
Dim rst2 As Recordset

Set db = CurrentDb
Set rst1 = db.OpenRecordset("tblAccountProfile", dbOpenDynaset)

rst1.Edit
rst1!TrainerID = Me.txtID
rst1!TrainerName = Me.txtName
rst1!TrainerRepType = Me.txtRepType
rst1.Update
rst1.Requery

MsgBox "Sales Rep information has been updated.", vbOKOnly, "Sales Rep
Information"

DoCmd.Close acForm, "frmSalesRepPopUp", acSaveNo
DoCmd.RepaintObject acForm, "frmAccountProfile"
Forms!frmAccountProfile.Refresh

Set rst1 = Nothing
Set db = Nothing

End Sub
'----------------------------

Thank you.

Henry
You could try this.
.....code at start line below
DoCmd.Close acForm, "frmSalesRepPopUp", acSaveNo

rst1.Close
Set rst1 = Nothing

Set rst1 = Forms!frmAccountProfile.Form.Recordsetclone
rst1.BookMark = Forms!frmAccountProfile.Form.BookMark
Forms!frmAccountProfile.Form.Requery
Forms!frmAccountProfile.Form.BookMark = rst1.Bookmark

rst1.Close
Set rst1 = Nothing
Set db = Nothing

End Sub
'----------------------------

Thank you.

Henry

Mar 7 '06 #2
salad <oi*@vinegar.com> wrote in
news:ja*****************@newsread1.news.atl.earthl ink.net:
You could try this.
....code at start line below
DoCmd.Close acForm, "frmSalesRepPopUp", acSaveNo

rst1.Close
Set rst1 = Nothing

Set rst1 = Forms!frmAccountProfile.Form.Recordsetclone
rst1.BookMark = Forms!frmAccountProfile.Form.BookMark
Forms!frmAccountProfile.Form.Requery
Forms!frmAccountProfile.Form.BookMark = rst1.Bookmark


A requery invalidates any bookmarks.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Mar 7 '06 #3
David W. Fenton wrote:
salad <oi*@vinegar.com> wrote in
news:ja*****************@newsread1.news.atl.earthl ink.net:

You could try this.
....code at start line below
DoCmd.Close acForm, "frmSalesRepPopUp", acSaveNo

rst1.Close
Set rst1 = Nothing

Set rst1 = Forms!frmAccountProfile.Form.Recordsetclone
rst1.BookMark = Forms!frmAccountProfile.Form.BookMark
Forms!frmAccountProfile.Form.Requery
Forms!frmAccountProfile.Form.BookMark = rst1.Bookmark

A requery invalidates any bookmarks.

Good catch. I thought something looked odd. Usually I get the record
ID and then after requerying find the record and set the bookmark.
Mar 8 '06 #4

salad wrote:
David W. Fenton wrote:
salad <oi*@vinegar.com> wrote in
news:ja*****************@newsread1.news.atl.earthl ink.net:

You could try this.
....code at start line below
DoCmd.Close acForm, "frmSalesRepPopUp", acSaveNo

rst1.Close
Set rst1 = Nothing

Set rst1 = Forms!frmAccountProfile.Form.Recordsetclone
rst1.BookMark = Forms!frmAccountProfile.Form.BookMark
Forms!frmAccountProfile.Form.Requery
Forms!frmAccountProfile.Form.BookMark = rst1.Bookmark

A requery invalidates any bookmarks.

Good catch. I thought something looked odd. Usually I get the record
ID and then after requerying find the record and set the bookmark.

==============
I almost have it! The problem is only the first record is updated. I
need to update the record that matches the criteria. Since this code
is at the top of the routine could this be the culprit?

rst1.Edit
rst1!TrainerID = Me.txtID
rst1!TrainerName = Me.txtName
rst1!TrainerRepType = Me.txtRepType
rst1.Update
rst1.Requery

Where should this go? Does this need to be separated?

Thanks again for the help.

Mar 8 '06 #5
Henry Stockbridge wrote:
salad wrote:
David W. Fenton wrote:
salad <oi*@vinegar.com> wrote in
news:ja*****************@newsread1.news.atl.ear thlink.net:

You could try this.
....code at start line below
DoCmd.Close acForm, "frmSalesRepPopUp", acSaveNo

rst1.Close
Set rst1 = Nothing

Set rst1 = Forms!frmAccountProfile.Form.Recordsetclone
rst1.BookMark = Forms!frmAccountProfile.Form.BookMark
Forms!frmAccountProfile.Form.Requery
Forms!frmAccountProfile.Form.BookMark = rst1.Bookmark
A requery invalidates any bookmarks.


Good catch. I thought something looked odd. Usually I get the record
ID and then after requerying find the record and set the bookmark.


==============
I almost have it! The problem is only the first record is updated. I
need to update the record that matches the criteria. Since this code
is at the top of the routine could this be the culprit?

rst1.Edit
rst1!TrainerID = Me.txtID
rst1!TrainerName = Me.txtName
rst1!TrainerRepType = Me.txtRepType
rst1.Update
rst1.Requery

Where should this go? Does this need to be separated?

Thanks again for the help.


OK. First, I don't see you finding a record in "tblAccountProfile".
That is why I assumed there is only 1 record.

I'm not sure what frmAccountProfile is for. Why are you adding
something to a recordset and they requerying? For example, if you want
the values put into it, why not explicitly say so. Instead of opening
the table, why not do something like

Forms!frmAccountProfile!TrainerID = Me.txtID
Forms!frmAccountProfile!TrainerName = Me.txtName
Forms!frmAccountProfile!TrainerRepType = Me.txtRepType

and not bother requerying the form and opening tables and editting and
updating? IOW, forget this code.
Set db = CurrentDb
Set rst1 = db.OpenRecordset("tblAccountProfile", dbOpenDynaset)

rst1.Edit
rst1!TrainerID = Me.txtID
rst1!TrainerName = Me.txtName
rst1!TrainerRepType = Me.txtRepType
rst1.Update
rst1.close
set rst1 = Nothing

Or are you adding the values to a table that is used by the form that
has calcs that it really needs to be requeried? If so then...

Let's pretend that the key to this record is called ID

Sub AddRep_Click()

Dim db As Database
Dim rst1 As Recordset
Dim lngID As Long

Set db = CurrentDb
Set rst1 = db.OpenRecordset("tblAccountProfile", dbOpenDynaset)
'FIND THE RECORD
rst1.FindFirst "ID = " & Me.ID

'verify record found
If not rst1.NoMatch Then
'if found, update
rst1.Edit
rst1!TrainerID = Me.txtID
rst1!TrainerName = Me.txtName
rst1!TrainerRepType = Me.txtRepType
rst1.Update
Endif
rst1.close
set rst1 = Nothing

'set the ID from the form
lngID = Forms!frmAccountProfile!ID
'requery form to update
Forms!frmAccountProfile.Form.Requery
'now find and move to that record in the form's recordset
set rst1 = Forms!frmAccountProfile.Form.Recordsetclone
rst.FindFirst "ID = " & lngID
Forms!frmAccountProfile.Form.Bookmark = rst.Bookmark

MsgBox "Sales Rep information has been updated."

DoCmd.Close acForm, "frmSalesRepPopUp", acSaveNo

Set rst1 = Nothing
Set db = Nothing

End Sub
Mar 8 '06 #6
Thanks for the help. I am all set now.

Mar 9 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
3310
by: William Wisnieski | last post by:
Hello Everyone, Access 2000 I have a main form with a continuous subform. On the main form I have a text field called . It gets populated based on what the user selects in a field on the...
2
1875
by: Peter Oliphant | last post by:
I now have graphics being drawn in the Paint event of my form (yeah, and it's very cool). Problem was that it only updated any changes to these graphics when Paint was called. So, I then made it...
4
2024
by: John | last post by:
I get the feeling this is a pretty classic problem, but I'm a bit of an uber newber. Apologies! Products page, user enters a quantity and clicks one of my "Add to Cart" buttons, which bubbles up...
17
3289
by: Jim Little | last post by:
Hello, I'm driving myself crazy either because I'm missing something about ASP.NET, or what I'm trying to do simply can't be done. First, I am not using session variables to track state. My...
5
3556
by: Tmajarov | last post by:
Haven't been able to find a clear answer to this... I am building an asp.net application and trying to enforce some work flow by displaying a form via the showmodaldialog method. I can get the...
16
453
by: Adda | last post by:
If I cycle through the MdiChildActivate event of the parent form I can read text in a textbox on the child mdiform -- console.writeline(Me.ActiveMdiChild.Controls(1).Text) But if I have a sub...
22
4989
by: Br | last post by:
First issue: When using ADPs you no longer have the ability to issue a me.refresh to save the current record on a form (the me.refresh does a requery in an ADP). We usually do this before...
2
8154
by: Robert | last post by:
I am trying to give the user dynamic search capabilities to select almost any record in the database from criteria they select. Everything seems to work except when I open the display form to...
12
6004
by: martin1 | last post by:
All, is there window form refresh property? I try to set up window form refresh per minute. Thanks
0
1477
by: Niuh | last post by:
We've been using the following line of code in our VB.NET apps to refresh our Web forms that are pulling real-time data from a SQL database: Response.AppendHeader("Refresh", "10") But when this...
0
7205
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7093
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7287
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7006
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
7467
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
5592
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,...
1
5021
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...
0
4685
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
1
744
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.