-
WSD Willett
AskWoody LoungerSorry Hadn’t noticed you are running A97
Here’s the code behind the button;
Private Sub YourButtonName_Click()
Dim intButSelected As Integer, intButType As Integer
Dim strMsgPrompt As String, strMsgTitle As StringstrMsgPrompt = “You have Selected To Close This Form, Do You Want To Continue”
strMsgTitle = “Close Form”intButType = vbYesNo + vbQuestion + vbDefaultButton1
intButSelected = MsgBox(strMsgPrompt, intButType, strMsgTitle)If intButSelected = vbYes Then
Me.[YourDateFieldName] = Now()
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Me.Requery
DoCmd.closeElse
‘ NO button code…
End If
End SubHope this helps
Dave
-
WSD Willett
AskWoody LoungerNot really getting involved in the archive procedure, perhaps your line of would be better located some-where before the form is closed.
see the attached zip.
I’ve added a button on the form which when clicked, creates a message box asking the user if he wants to close the form, if he selects YES, then your code will be run. If NO, the form stays open.
Hope this helps.
Check the code behind the button and change the field names to what you need.
If this is ok, you can then disable the crosshair thru properties.
Dave
p.s Put the Me.requery before the DoCmd.close bit.
-
WSD Willett
AskWoody LoungerDo you have an example of the on close event event procedure or even attach a demo of the form.
-
WSD Willett
AskWoody LoungerThanks Charlotte, It was the format part I was looking for, I can take it from there.
I didn’t want to use the form as the report, I think that way looks messy some-times.
I can’t find ADO 2.5 in my references, should it be ?Cheers all
Dave
-
WSD Willett
AskWoody LoungerHere it is again fixed, it should open ok now
-
WSD Willett
AskWoody LoungerYes
I’ve been having similar problems to this since upgrading to SR1Any body any suggestions.
Dw
-
WSD Willett
AskWoody LoungerThanks for that,
Dave
-
WSD Willett
AskWoody LoungerWell.
Cheers for that Hans, never thought it would be that easy.Thanks
Dave -
WSD Willett
AskWoody LoungerThanks all, I can take it from here.
Dave
-
WSD Willett
AskWoody LoungerSorry to be a pain, one final thing.
If I want to use lets say VbKeyF3 to do more than one task on the same form.
Which is the correct way, Example 1 or Example 2
(Example 1)
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
On Error GoTo ERRTRAP
Select Case KeyCode
Case vbKeyF5
Call Command19_Click
KeyCode = 0
Case vbKeyF3
Me.sbfLabourBooking.SetFocus
KeyCode = 0
Case vbKeyF3
DoCmd.GoToRecord , , acNewRec
KeyCode = 0
Case vbKeyF3
Me.EstimateNo = Forms!frmlabourbooking!txtSearchEstimateNo.Value
KeyCode = 0
Case vbKeyF3
Me.supp = Forms!frmlabourbooking!txtSearchSupp.Value
KeyCode = 0
End Select
Exit Sub
ERRTRAP:
End Sub(Example 2)
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
On Error GoTo ERRTRAP
Select Case KeyCode
Case vbKeyF5
Call Command19_Click
KeyCode = 0
Case vbKeyF3
Me.sbfLabourBooking.SetFocus
DoCmd.GoToRecord , , acNewRec
Me.EstimateNo = Forms!frmlabourbooking!txtSearchEstimateNo.Value
Me.supp = Forms!frmlabourbooking!txtSearchSupp.Value
KeyCode = 0
End Select
Exit Sub
ERRTRAP:
End Subthanks again
Dave -
WSD Willett
AskWoody LoungerThanks again Hans.
This makes things much clearer, ( Have a lot of editing to do noe.)
Dave
-
WSD Willett
AskWoody LoungerI notice Hans you use “select Case”, maybe I need to do the same with my code:
Private Sub cmbClientCode_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyDown Then Me.CmbRegistration.SetFocus
If KeyCode = vbKeyUp Then Me.cmbInsurerCode.SetFocus
If KeyCode = vbKeyF11 Then
If Me.cmbClientCode.ListIndex > 0 Then
Me!cmbClientCode.ListIndex = Me!cmbClientCode.ListIndex – 1
End If
End If
If KeyCode = vbKeyF12 Then
If Me.cmbClientCode.ListIndex < Me.cmbClientCode.ListCount – 1 Then
Me!cmbClientCode.ListIndex = Me!cmbClientCode.ListIndex + 1
End If
End If
If KeyCode = vbKeyF2 Then Call cmbClientCode_DblClick(1)
End SubI use quite a few KeyCode combinations, can you steer me in the right direction here. I needed to use the VbKeyRight & Left to replace the F11 & F12 parts of the code, but when I do, I get odd happenings.
I assume the Access default action for the keys is kicking in at the same time as I call them through code.Dave
-
WSD Willett
AskWoody LoungerI’ve done it.
Set all subs to visible=false then true when the main opens.
Now, the subs open exactly on time with the main.
Thanks once again Hans
Dave
-
WSD Willett
AskWoody LoungerSo close. It works and helps the main to appear quicker when it is called.
But
When opening the menu, the main form very briefly appears and then goes to hidden.DoCmd.OpenForm FormName:=”frmMyForm”, WindowMode:=acHidden
I wonder if the form can be made invisible before it loads ???
Dave
-
WSD Willett
AskWoody LoungerThanks again Hans,
I’ll give it some thought, your way seems to in the direction I need.
Basically take the caldulation direct from the table instead of the form. Its a bit clearer now.dave
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Outdated Laptop
by
jdamkeene
2 hours, 42 minutes ago -
Updating Keepass2Android
by
CBFPD-Chief115
8 hours, 7 minutes ago -
Another big Microsoft layoff
by
Charlie
7 hours, 47 minutes ago -
PowerShell to detect NPU – Testers Needed
by
RetiredGeek
7 hours, 36 minutes ago -
May 2025 updates are out
by
Susan Bradley
8 hours, 11 minutes ago -
Windows 11 Insider Preview build 26200.5600 released to DEV
by
joep517
13 hours, 51 minutes ago -
Windows 11 Insider Preview build 26120.3964 (24H2) released to BETA
by
joep517
13 hours, 52 minutes ago -
Drivers suggested via Windows Update
by
Tex265
13 hours, 43 minutes ago -
Thunderbird release notes for 128 esr have disappeared
by
EricB
11 hours, 28 minutes ago -
CISA mutes own website, shifts routine cyber alerts to X, RSS, email
by
Nibbled To Death By Ducks
20 hours, 43 minutes ago -
Apple releases 18.5
by
Susan Bradley
15 hours, 8 minutes ago -
Fedora Linux 40 will go end of life for updates and support on 2025-05-13.
by
Alex5723
22 hours, 9 minutes ago -
How a new type of AI is helping police skirt facial recognition bans
by
Alex5723
22 hours, 47 minutes ago -
Windows 7 ISO /Windows 10 ISO
by
ECWS
6 hours, 3 minutes ago -
No HP software folders
by
fpefpe
1 day, 6 hours ago -
Which antivirus apps and VPNs are the most secure in 2025?
by
B. Livingston
3 hours, 47 minutes ago -
Stay connected anywhere
by
Peter Deegan
1 day, 11 hours ago -
Copilot, under the table
by
Will Fastie
1 day, 3 hours ago -
The Windows experience
by
Will Fastie
1 day, 18 hours ago -
A tale of two operating systems
by
Susan Bradley
1 hour, 41 minutes ago -
Microsoft : Resolving Blue Screen errors in Windows
by
Alex5723
1 day, 23 hours ago -
Where’s the cache today?
by
Up2you2
2 days, 14 hours ago -
Ascension says recent data breach affects over 430,000 patients
by
Nibbled To Death By Ducks
2 days, 7 hours ago -
Nintendo Switch 2 has a remote killing switch
by
Alex5723
1 day, 7 hours ago -
Blocking Search (on task bar) from going to web
by
HenryW
10 hours, 5 minutes ago -
Windows 10: Microsoft 365 Apps will be supported up to Oct. 10 2028
by
Alex5723
3 days, 7 hours ago -
Add or Remove “Ask Copilot” Context Menu in Windows 11 and 10
by
Alex5723
3 days, 8 hours ago -
regarding april update and may update
by
heybengbeng
3 days, 9 hours ago -
MS Passkey
by
pmruzicka
2 days, 11 hours ago -
Can’t make Opera my default browser
by
bmeacham
3 days, 17 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.