Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 8th, 2003, 09:24 AM
Registered User
 
Join Date: Aug 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default program code for "save" (F9) command

Hi,
I'm new in MS access programming and can not come over a properly simply thing..
How can I force in VB code the F9 command ?
Thanks for any assistance
Mario


 
Old August 8th, 2003, 10:08 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Quote:
quote:Originally posted by mario_fluegge
How can I force in VB code the F9 command ?
You want to save a record? Look here for a similar question and answers:

http://p2p.wrox.com/topic.asp?TOPIC_ID=2686

Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old August 8th, 2003, 11:03 AM
Registered User
 
Join Date: Aug 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Greg, thanks,
but this is not what I was looking for.
I have several users working with one table ect. database, if someone add a new record, it will be seen by others only after F9 was pushed.
So I actually was looking for a code expression, which substitutes the F9 pushing and which I can place at any relevant place or after certain activity.
Mario


 
Old August 8th, 2003, 04:50 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

Hi Mario,

If you need to programmatically send keystrokes to your app, you'll need functionality similar to the SendKeys statement, but avoid using the SendKeys statement itself (too unpredictable). There is a replacement module for SendKeys that uses API calls at:

http://www.mvps.org/access/api/api0046.htm

This kind of functionality is rarely necessary though. What your F9 key is accomplishing is a simple refresh of the cursor storing the contents of your recordset. This refresh is necessary because the Jet OLEDB Provider doesn't support dynamic cursors (a type of cursor that allows edits, deletions, and insertions made by other users to be visible.) Jet is giving you a Keyset cursor (most likely) which allows you to see edits and deletions, but not insertions. Pressing F9 refreshes the Keyset cursor, which is equivalent to closing and reopening the recordset.

All of this behavior can be controlled programmatically using ADO or DAO. If, for example you populate your form using a module-level ADO recordset named m_rstMyRecordset, you could accomplish your refresh by placing a command button on your form, and placing the following code behind it:

Private Sub cmdRefresh_Click()
    m_rstMyRecordset.Requery
End Sub

The Requery method reloads your cursor with fresh data from your datasource, including records recently inserted by other users. You don't have to mess with unreliable sendkey statements or messy API calls. And you could call the Requery method from any procedure that can see your recordset variable.

(note: you'll notice that the ADO Recordset CursorType property enum has a adOpenDynamic value available. If you send this value to the Jet engine, you'll actually get back a Keyset cursor (using optimistic, pessimistic, or batch optimistic locking) or a Static cursor (using read-only locking). You can't get Jet to give you a Dynamic cursor.)

HTH,

Bob





Similar Threads
Thread Thread Starter Forum Replies Last Post
Program Code Errors ed123 Beginning PHP 0 September 8th, 2007 03:53 AM
F9-key grstad Excel VBA 3 February 26th, 2007 01:45 PM
run code on save?? Vince.Bixby Word VBA 3 December 29th, 2006 04:28 AM
Save printer for my program pavel Access VBA 1 June 23rd, 2004 01:21 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.