Hi,
I have a form which contains some dates and some calculated fields based on these dates e.g. Days until contract expires (difference between today and contract end date) etc....I also have an update button that re-calculates the derived fields if the dates are manually changed.
The update button has the following macro behind it:
SetWarnings
Requery
OpenQuery
OpenQuery (update queries)
OpenQuery
Requery
Save
Msgbox
If i am updating record 123 for example, when i press the update button it goes back to the first record. I know this is due to the Requery statement but i cant take this out as it will not update my record.
Do you know how to prevent it going to the first record and keeping it on the record i was editing once i press the update button??
thanks
8 2019
Can anyone help with this? If they need me to explain to problem clearer please let me know.
thanks
Can anyone help with this? If they need me to explain to problem clearer please let me know.
thanks
Given you are using macros the logic would be to identify your primary key control on your form and its current value prior to any activity of updating taking place. This would give you the pointer to return to.
Your trick would then to pass this value to an unbound screen control that you could hide on screen by using the SETVALUE macro command. You could then invoke the process and then end the sequence with a GOTOCONTROL action (your primary key field the cursor needs to sit in the field itself) and then FINDRECORD action in the macro the syntax of that in the 'Find What' arguments section would simply reference your unbound control like this =[MyFieldName] where the 'find record' action is finding the value that exists in the hidden field
You might want to include the macro action 'echo' to turn off screen updates during the process and turn then back on at the appropriate point thereby reducing to the eye the visual shifts in records that the process would inevitably otherwise show.
Hope this helps you
Regards
Jim :)
Hi Jim,
Thanks for your quick response. The logic seems to make sense by using a pointer, but i cant understand the difference between setvalue / Gotocontrol & FindRecord options.
I have aprrox 200 records, but the primary key isn't simply 1-200, one record might have a primary key of 34A-7, so when i tell the macro to either go to or find =[Primary Key] its says that no record exists?
Is there any chance you could tell me in a more simpler / idoits way, so i can grasp it better.
Thanks for all your help.
James
Hi Jim,
Thanks for your quick response. The logic seems to make sense by using a pointer, but i cant understand the difference between setvalue / Gotocontrol & FindRecord options.
I have aprrox 200 records, but the primary key isn't simply 1-200, one record might have a primary key of 34A-7, so when i tell the macro to either go to or find =[Primary Key] its says that no record exists?
Is there any chance you could tell me in a more simpler / idoits way, so i can grasp it better.
Thanks for all your help.
James
I'll see if I can replicate your scenario using a simple db that i will create James my end and post it as an attachment. Obviously it will be rather generic by nature (as I don't know exactly what you have there) and you will have adjustments to make but give me some time (have meetings today) but this evening will address it and hopefully you'll gain an understanding I will also try and introduce similarities by doing it in code. (which you I take it will not be familar with but at least it gives you differences to chew over and examine)
Regards
Jim :)
Thanks for all your efforts Jim.
I look forward to hearing from you.
Cheers
James
Thanks for all your efforts Jim.
I look forward to hearing from you.
Cheers
James
ok James,
As promised..attac hed is a simple database that demonstrates what I was talking about. In it you will see it open a form called frmYourForm which is something like I visualise you having your end. The form displays two editable dates derived from a table upon which the form is based as its control source. The form has a number of demo functions that work off the date from editable field things like day of week and so on. This form demonstrates the find by the macro action based on the contents of a hidden field. The macro called mcrMyMacro has the relevant actions needed to do what you were seeking to do and that is refind the current record.
On this same form is a button that opens a form called frmMyForm which is based on a 'query' as its control source....subtl e difference and included basically to show you that differences can be had here in terms of method.
Examine the differences between the two forms and the way that using a 'query' on which to base your form has advantages in the sense that you can embed your calculations (as it were) in the query at which point they become useable columns in an underlying dataset
The two forms essentially look the same but I have coloured them differently so you can tell which one you have open more readily.
On the form frmMyForm examine the code behind the form and see how very much less is required to do what you need to do when you couple useage of a query as the basis for a forms controlsource and using together with code to perform the updating actions instead of a macro. Macros do not have error handling as part of their makeup and are less powerful than the coding method overall but do have advantages in that to the non coder they are user friendly.
Hope this goes some way to helping you
Regards
Jim
Jim,
You are a gentleman! Thank you ever so much for your help.
I have finally got it to work, and have managed to simplify it slightly.
Cheers.
James
Jim,
You are a gentleman! Thank you ever so much for your help.
I have finally got it to work, and have managed to simplify it slightly.
Cheers.
James
Glad to be of help
Jim :)
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Scott |
last post by:
I have created a form that has a few combo boxes on it. On the form I
have ComboBoxA which selects data from a region, and ComboBoxB that
selects individual locations within a selected region. I need to
figure out the correct way to Requery ComboBoxA after I have updated
it. I searched the archive for this list and found a simple solution:
put Me.Requery in the AfterUpdate event of ComboBoxA. However, when
I try this I get an error...
|
by: Dos Lil |
last post by:
I have a comobox in the main form which has a query attached to it to
list the employee numbers.I have written this code to requry the control
in the control's after update event
Private Sub CBOEmpNo_AfterUpdate()
Me!.Requery
End Sub
but still I am getting error
|
by: M Wells |
last post by:
Hi All,
I am developing an Access 2003 project application with the back end
in SQL Server 2003.
I have a master form that tracks projects, and several subforms on it
that track various aspects of the project. On the masterform I have
two unbound listboxes that I populate with information regarding the
current record in one of the subforms.
|
by: deko |
last post by:
I'm a little nervous about slamming my database with a dozen Update queries
in a loop that all modify RecordSources of open forms. Will the use of
DoEvents and/or a Sleep function ameliorate any risk involved in doing this?
Should I include a Requery in the loop after executing each query?
For example:
For each varQry in Array("qryDeleteOldTransactions", _
"qryDeleteClient Acct", etc., etc.)
db.Execute varQry
|
by: MS |
last post by:
Access 97
I want to requery the data being displayed on a form, then I want to return
to the record I was in.
Why doesn't this code work?
Private Sub CmdRefsh_Click()
| |
by: ken |
last post by:
Hi,
In my after_insert event on a form I add additional records to the
table. The problem I'm running into is that I need for those records to
show up after the after_insert event ends. If I requery the form during
but at the end of after_insert I don't see the recently added
records(using VBA the INSERT statement). However if I use a refresh
button(onclick me.requery) then I see the records. But I need to see
the records at the end of...
|
by: SBC News Groups |
last post by:
I have a form that the user enters some information on and then clicks a
button to save the record. I do with the following line:
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Once this line executes, I have a sub form that I want to "refresh" because
the newly saved information should now display on the sub form. I am trying
to do this with this line:
Forms!.Requery
|
by: mrowe |
last post by:
I am using Access 2003. (I am also using ADO in the vast majority of my code. I recently read a post that indicated that ADO is not all that is was initially cracked up to be. In the back of my mind I am wonder if this is causing my problem, but I don’t want to go through the work to convert to DAO unless I know it is truly in my best interest.)
I am having problems getting a requery to show up consistently on a couple of forms. I have...
|
by: theaybaras |
last post by:
Hi All...
I've read both of the requery discussions I could find...
Refresh ComboBox After Adding New Values via a Seperate Form
and
refresh a form
but am not quite able to get this to apply to my database.
I have a table/form called Author_Info where information about authors is entered. The fields of interest here are:
Author_Last
Author_First
|
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,...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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...
|
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...
|
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();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |