473,837 Members | 1,811 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.OpenRecordse t("tblAccountPr ofile", dbOpenDynaset)

rst1.Edit
rst1!TrainerID = Me.txtID
rst1!TrainerNam e = Me.txtName
rst1!TrainerRep Type = Me.txtRepType
rst1.Update
rst1.Requery

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

DoCmd.Close acForm, "frmSalesRepPop Up", acSaveNo
DoCmd.RepaintOb ject acForm, "frmAccountProf ile"
Forms!frmAccoun tProfile.Refres h

Set rst1 = Nothing
Set db = Nothing

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

Thank you.

Henry

Mar 7 '06 #1
6 8534
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.OpenRecordse t("tblAccountPr ofile", dbOpenDynaset)

rst1.Edit
rst1!TrainerID = Me.txtID
rst1!TrainerNam e = Me.txtName
rst1!TrainerRep Type = Me.txtRepType
rst1.Update
rst1.Requery

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

DoCmd.Close acForm, "frmSalesRepPop Up", acSaveNo
DoCmd.RepaintOb ject acForm, "frmAccountProf ile"
Forms!frmAccoun tProfile.Refres h

Set rst1 = Nothing
Set db = Nothing

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

Thank you.

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

rst1.Close
Set rst1 = Nothing

Set rst1 = Forms!frmAccoun tProfile.Form.R ecordsetclone
rst1.BookMark = Forms!frmAccoun tProfile.Form.B ookMark
Forms!frmAccoun tProfile.Form.R equery
Forms!frmAccoun tProfile.Form.B ookMark = rst1.Bookmark

rst1.Close
Set rst1 = Nothing
Set db = Nothing

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

Thank you.

Henry

Mar 7 '06 #2
salad <oi*@vinegar.co m> wrote in
news:ja******** *********@newsr ead1.news.atl.e arthlink.net:
You could try this.
....code at start line below
DoCmd.Close acForm, "frmSalesRepPop Up", acSaveNo

rst1.Close
Set rst1 = Nothing

Set rst1 = Forms!frmAccoun tProfile.Form.R ecordsetclone
rst1.BookMark = Forms!frmAccoun tProfile.Form.B ookMark
Forms!frmAccoun tProfile.Form.R equery
Forms!frmAccoun tProfile.Form.B ookMark = 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.co m> wrote in
news:ja******** *********@newsr ead1.news.atl.e arthlink.net:

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

rst1.Close
Set rst1 = Nothing

Set rst1 = Forms!frmAccoun tProfile.Form.R ecordsetclone
rst1.BookMa rk = Forms!frmAccoun tProfile.Form.B ookMark
Forms!frmAcco untProfile.Form .Requery
Forms!frmAcco untProfile.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.co m> wrote in
news:ja******** *********@newsr ead1.news.atl.e arthlink.net:

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

rst1.Close
Set rst1 = Nothing

Set rst1 = Forms!frmAccoun tProfile.Form.R ecordsetclone
rst1.BookMa rk = Forms!frmAccoun tProfile.Form.B ookMark
Forms!frmAcco untProfile.Form .Requery
Forms!frmAcco untProfile.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!TrainerNam e = Me.txtName
rst1!TrainerRep Type = 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.co m> wrote in
news:ja***** ************@ne wsread1.news.at l.earthlink.net :

You could try this.
....code at start line below
DoCmd.Clo se acForm, "frmSalesRepPop Up", acSaveNo

rst1.Clos e
Set rst1 = Nothing

Set rst1 = Forms!frmAccoun tProfile.Form.R ecordsetclone
rst1.BookMa rk = Forms!frmAccoun tProfile.Form.B ookMark
Forms!frmAc countProfile.Fo rm.Requery
Forms!frmAc countProfile.Fo rm.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!TrainerNam e = Me.txtName
rst1!TrainerRep Type = 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 "tblAccountProf ile".
That is why I assumed there is only 1 record.

I'm not sure what frmAccountProfi le 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!frmAccoun tProfile!Traine rID = Me.txtID
Forms!frmAccoun tProfile!Traine rName = Me.txtName
Forms!frmAccoun tProfile!Traine rRepType = 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.OpenRecordse t("tblAccountPr ofile", dbOpenDynaset)

rst1.Edit
rst1!TrainerID = Me.txtID
rst1!TrainerNam e = Me.txtName
rst1!TrainerRep Type = 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.OpenRecordse t("tblAccountPr ofile", 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!TrainerNam e = Me.txtName
rst1!TrainerRep Type = Me.txtRepType
rst1.Update
Endif
rst1.close
set rst1 = Nothing

'set the ID from the form
lngID = Forms!frmAccoun tProfile!ID
'requery form to update
Forms!frmAccoun tProfile.Form.R equery
'now find and move to that record in the form's recordset
set rst1 = Forms!frmAccoun tProfile.Form.R ecordsetclone
rst.FindFirst "ID = " & lngID
Forms!frmAccoun tProfile.Form.B ookmark = rst.Bookmark

MsgBox "Sales Rep information has been updated."

DoCmd.Close acForm, "frmSalesRepPop Up", 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
3342
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 sub form (code in the AfterUpdate Event). Here's the issue. If the user deletes a subform record. The field on the main form shows null even if there is a value in the preceding subform record. What I'd like it to do is immediately refresh to
2
1899
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 so the Refresh() method of the form was called for each graphic object. In this case it drew just fine, but Paint was being called so often I lost control of the form (e.g., trying to close the form using the close 'x' in upper right corner...
4
2034
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 through the datalist and calls a method to AddToCart(cartID,prodID,prodQty). Now, if the user clicks 'refresh', that method is executed again without clicking the button. So if they add 2 apples, refresh, they have 4 apples, refresh, 6 apples,...
17
3313
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 app will ultimately be web-farmed, so I resisted using either session variables. Second, what I'm trying to do is easy. What I'm trying to prevent seems impossible.
5
3591
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 form to display, etc. But I want to refresh the content of the form displayed in the dialog window without navigating away from the form. For example... the showdialog method opens up a record to be edited. After editing when the save(submit)...
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 in the Parent form and reference a child mdi form like this: Sub ReadText()
22
5058
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 calling up another form or report that uses some of the same data. We came up with a work around that saves the current record's ID, does a
2
8182
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 display the data to the user. If that form is already open, how do I make it refresh its data source and display the new data. Here is what I am doing. >From a text entry form, I create an SQL query dymanically and alter the sql statement of an...
12
6051
by: martin1 | last post by:
All, is there window form refresh property? I try to set up window form refresh per minute. Thanks
0
1490
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 is done the form always flickers. That's the 1st problem. The second problem is that I have a form that I want to refresh some of the data, but don't want to re-run the whole form because I need to retain the user's last selection on the form. I...
0
9846
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9685
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10277
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9413
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7817
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7007
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4479
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4052
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3126
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.