I have a super simple Access DB with four tables and one form.. I'm an old hand at Excel VBA but am just starting with Access, so this is likely a totally stupid question, but here goes anyway.
In Form_Load() for the form, I have a time based trigger that lets the DB execute a macro and automatically quit when the macro is completed so I can run overnight maintenance where it runs some SQL queries on external databases, and builds an Excel workbook and a Word document based on the query.
It (form_load()) opens a recordset, and works with the recordset.
However, the macros that generate the Excel and Word files actually work with the FORM itself.
Here's the problem -- when my user manually runs the macros via commandbuttons on the form, they work great; it pulls the data from the selected record, generates the files, and they giggle and clap.
When I schedule a task to execute it via form_load(), however, it opens the recordset, scans through it, and then it runs the macros.. but the macros don't select any item on the form, so it always generates data for record 1 or 0 or...whatever.
How do I tell form_load() to actually go through the motions of selecting the form record as it processes the recordset fields so it's pointed at the right data?
5 2730 Rabbit 12,516
Recognized Expert Moderator MVP
If your recordset is the same as the record source for the form, then you can set them to the same record using: -
Me.Recordset.Bookmark = YourRecordset.Bookmark
-
It doesn't seem to like Me.Recordset.Bo okmark. (I'm using Access 2000, if that makes a difference.)
If I just add Me.Bookmark = rs.Bookmark, I get an error of "Not a valid bookmark."
Watches on these show the following:
Me.Bookmark:
Me.Bookmark(0) = 0
Me.Bookmark(1) = 2
Me.Bookmark(2) = 0
Me.Bookmark(3) = 0
rs.Bookmark:
rs.Bookmark(0) = 0
rs.Bookmark(1) = 21
rs.Bookmark(2) = 0
rs.Bookmark(3) = 0
Here's my form_load(), modified a little for debugging: Rabbit 12,516
Recognized Expert Moderator MVP
Sorry, I was trying to go off the top of my head. I think you have to use: -
Set Me.Bookmark = rst.Bookmark
-
Edit: Scratch that. You don't need the Set. Are you sure your recordset is the same as the form? You might want to try: -
Set rs = Me.RecordsetClone
-
Eureka! RecordsetClone worked, OpenRecordset didn't. :)
Thanks much, Rabbit! That made my 4 day xmas weekend much nicer.. no having to remote in from home to click a button once a day! :)
Rabbit 12,516
Recognized Expert Moderator MVP
Not a problem, good luck.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Zlatko Matiæ |
last post by:
There is a form (single form) and a combobox. I want that current record of
the form is adjusted according to selected value in the combobox. Cuurrent
record should be the same as the value in the combobox.
What is the solution?
Thank you in advance.
|
by: Susan Bricker |
last post by:
Greetings. I have a Mainform with a subform. The Mainform has single
record format and subform has continuous form format. When the Mainform
opens, I force allowadditions and allowedits to FALSE (for both the
Mainform and Subform). No problem there.
However, when I click on the navigation control of the subform to move
to the next record in the subform, the AllowAdditions and AllowEdits
changes to TRUE. Not good.
I set...
|
by: Jamey Shuemaker |
last post by:
Howdy,
Saw a couple threads from the past few years on this topic, but didn't
really find any solutions.
Here's one I found:
http://groups.google.com/group/comp.databases.ms-access/browse_frm/thread/f6ccff0186d12566/
That fella wanted to do pretty well the same thing I did (use a command
button to move between records in a form). Moving from record to record
|
by: njb35 |
last post by:
Hi all
I'm beginning my foray from VBA into VB 2005 Express, and enjoying
some of the efficiencies it provides! I'm stuck with some dataset
handling however that I _think_ can be automated but I can probably
code what I want to do the hard way. I've searching around online but
can't find an answer to this specific question.
Here's the situation: I have a dataset table with 3 fields: one
indexed as a primary key and the other two...
|
by: sara |
last post by:
Hi -
I have been struggling with solution ideas for this now for almost 2
weeks, and have not been able to figure this out.
I have a user who creates a Purchase Order (tblPOData). In some
circumstances, this or another user must create an invoice to go with
the PO (I know - that makes no sense, but this is the business
case).
I have the user go to a form to create the invoice:
| |
by: Sunray |
last post by:
I have a form called the sales form and i have 2 sets of listboxes
So what happens is. i add items form the bottom set of list boxes which are bound to a data base to the top set of list boxes which are not bound, I select from the bottom set and add to the top set which works fine, but now i decide to remove an item from the top set.
when i tried to use a remove item code it worked fine, it did delete the item form the list but it added...
|
by: zivon |
last post by:
is there a way to excute a command on record change ?
I used form_load to check something, but when I go to the next/previews record it doesn't recheck..
Private Sub Form_Load()
If RefBy.Value = "test" Then
ReferredID.Enabled = True
End If
End Sub
|
by: QntmPg |
last post by:
Hi all,
I have read through what I could find on previous questions regarding using the OpenArgs property, but I'm still not able to get my form to open correctly. I'm not sure exactly where the problem is, so I'll try to describe what I'm doing in as much detail as I can. Any help is greatly appreciated!
I am building a database in Access 2003 to keep track of who participates in a study in our lab, and what study/ies they participate...
|
by: woodey2002 |
last post by:
Hi Everyone and many thanks for your time.. I am trying to begin access and a bit of VBA i am enjoying it but I have a annoying problem I just can’t get any where on.
My databse mostly includes bits of code for different examples. I have one last thing to finish.
I am trying to create a search form that will allow users to select criteria from multiple sources eg ,multi select list boxes , combo boxes.
I have a subform showing all the...
|
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: 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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
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: 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...
|
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...
| |