-
WSD Willett
AskWoody LoungerI shall go along with your recommendations greatfully.
There is nothing wrong with nit picking..
Thanks
Dave
-
WSD Willett
AskWoody LoungerHans
You caught me out again, Yes i’m a little scruffy where code is concerned.
I promise to use the Select Case in the future and I will write it out 100 times as punishment.Edited. The select case did the trick.
Thanks Hans.
Any other recommendations would be appreciated on my code.
Dave -
WSD Willett
AskWoody LoungerCheck the code (cmdInsertPic) this uses a common dialog box.
This opens at a specified drive and folder but with the option to browse any drive & folder.
You will need the (on current) event also.As you see mines a little bit of a hybrid to say the least. I will eventually remove the common dialog once I get it to work correctly.
I think the fault in my code is the (on Current) event conflicting.
Dave
-
WSD Willett
AskWoody LoungerHers pic2 showing the navigation bar and the fields at the top of the form
-
WSD Willett
AskWoody LoungerThe whole thing is working but I have a knawing problem with it.
Perhaps if I break it down, some-one will see whats happening.
Now, when I try to open the form, if there is no record, then the message box states the obvious, “You have no images”
———————————————————————————————————————————————
Private Sub Form_Open(Cancel As Integer)
DoCmd.Close acForm, “frmCreateEstimate”, acSaveYes
If Me.RecordsetClone.RecordCount = 0 Then
MsgBox “You Have No Current Images For This File, Press OK”
Me.lstPreviewJpgs.SetFocus
End If
End Sub
—————————————————————————————–Press ok and the form opens with all blank fields waiting for a selected picture.
The user has the focus in the list (lstPreviewJpgs) and uses the up / down arrow keys to go to a selection. This part is fine and the previewOLE (ignore OLE, its only a name) changes ok as it should.
——————————————————————————————
Private Sub lstPreviewJpgs_AfterUpdate()
Me!PreviewOLE.Picture = “L:Home” & Me!lstPreviewJpgs
Forms!frmImages.SetFocus
Forms!frmImages.lstPreviewJpgs.SetFocus
End Sub
—————————————————————————————————————————————Now, here’s where the glitch is, on KeyDown the user press’s Enter when he has reached the picture of his selection.
————————————————————————————-
Private Sub lstPreviewJpgs_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
DoCmd.GoToRecord , , acNewRec
Me.EstimateNo = Forms!frmDetails!EstimateNo
Me.supp = Forms!frmDetails!supp
Me.txtRegistration = Forms!frmDetails!Registration
Me.PicFile = “L:Home” & Me.lstPreviewJpgs
‘Me.PicFile = Me.lstPreviewJpgs
Me.[imgPicture].Picture = [PicFile]
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Forms!frmImages.SetFocus
Forms!frmImages.lstPreviewJpgs.SetFocus
Else
End If
On Error GoTo errtrap
If KeyCode = vbKeyPageUp Then Me.txtRegistration.SetFocus
If KeyCode = vbKeyPageUp Then DoCmd.GoToRecord , , acPrevious
If KeyCode = vbKeyPageDown Then Me.txtRegistration.SetFocus
If KeyCode = vbKeyPageDown Then DoCmd.GoToRecord , , acNext
errtrap:
Exit Sub
End Sub
——————————————————————————————————————-The code correctly assigns EstimateNo, Supp, Registration into a new record, saves it BUT, Looking at the navigation bar at the bottom of the form, the record number is now 2.
Its saved the first record with all ness details but moved over to record number 2.
If the form is closed and re-opened, the correct record number is at 1.Below I have pasted all the code from the form in case I have missed something.
—————————————————————————-
—————————————————————————-Option Compare Database
Option ExplicitPublic Function Proper()
Screen.ActiveControl = StrConv(Screen.ActiveControl, vbProperCase)
End FunctionPrivate Sub cmdClose_Click()
On Error Resume Next
DoCmd.Close acForm, Me.Name
End SubPrivate Sub cmdErasePic_Click()
If Not IsNull([PicFile]) Then
If MsgBox(“The image will be removed from this record. Are you sure?”, vbYesNo + vbQuestion) = vbYes Then
[imgPicture].Picture = “”
[PicFile] = Null
[EstimateNo] = Null
[supp] = Null
[Registration] = Null
[ImageCreated] = Null
[Comment] = Null
DoCmd.SetWarnings False
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
DoCmd.SetWarnings True
SysCmd acSysCmdClearStatus
Forms!frmImages.Requery
End If
End If
End SubPrivate Sub cmdInsertPic_Click()
If Me.RecordsetClone.RecordCount = 0 Then MsgBox “You No Current Images For This File, Press OK”
Dim OFN As OPENFILENAME
On Error GoTo Err_cmdInsertPic_Click
DoCmd.GoToRecord , , acNewRec
Me.EstimateNo = Forms!frmDetails!EstimateNo
Me.supp = Forms!frmDetails!supp
Me.txtRegistration = Forms!frmDetails!Registration
‘ Set options for dialog box.
With OFN
.lpstrTitle = “Images”
If Not IsNull([PicFile]) Then .lpstrFile = [PicFile]
.lpstrInitialDir = “L:home”
.flags = &H1804 ‘ OFN_FileMustExist + OFN_PathMustExist + OFN_HideReadOnly
.lpstrFilter = MakeFilterString(“Image files (*.bmp;*.gif;*.jpg;*.wmf)”, “*.bmp;*.gif;*.jpg;*.wmf”, _
“All files (*.*)”, “*.*”)
End With
If OpenDialog(OFN) Then
[PicFile] = OFN.lpstrFile
[imgPicture].Picture = [PicFile]
SysCmd acSysCmdSetStatus, “Image Loaded: ‘” & [PicFile] & “‘.”
Forms!frmImages.SetFocus
Me.EstimateNo.SetFocus
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
End If
Exit Sub
Err_cmdInsertPic_Click:
MsgBox Err.Description, vbExclamation
End SubPrivate Sub cmdPreview_Click()
On Error GoTo HandleErr
Dim intButSelected As Integer, intButType As Integer
Dim strMsgPrompt As String, strMsgTitle As String
strMsgPrompt = “You Have Selected To Print, Do You Want To Continue !!”
strMsgTitle = “Printing ”
intButType = vbYesNo + vbDefaultButton2
intButSelected = MsgBox(strMsgPrompt, intButType, strMsgTitle)
If intButSelected = vbYes Then
If IsNull([EstimateNo]) Then
MsgBox “There is no data for this report. Canceling report…”, vbInformation
Else
RunCommand acCmdSaveRecord
DoCmd.OpenReport “Image Thumbs”, acNormal, , “[EstimateNo] = ” & [EstimateNo]
Forms!frmImages.SetFocus
Forms!frmImages!EstimateNo.SetFocus
If intButSelected = vbNo Then
Forms!frmImages.SetFocus
Forms!frmImages!EstimateNo.SetFocus
End If
End If
End If
Exit Sub
HandleErr:
MsgBox Err.Description, vbExclamation
End SubPrivate Sub Command64_Click()
‘setfocu back to the list box
Me.lstPreviewJpgs.SetFocus
End SubPrivate Sub Form_Close()
On Error GoTo errtrap
Forms!frmDetails.SetFocus
Forms!frmDetails!DummyEst.SetFocus
Exit Sub
errtrap:
End SubPrivate Sub Form_Current()
On Error GoTo HandleErr
If Not IsNull([PicFile]) Then
Me.[imgPicture].Picture = [PicFile]
SysCmd acSysCmdSetStatus, “Image: ‘” & [PicFile] & “‘.”
Else
‘[imgPicture].Picture = “”
SysCmd acSysCmdClearStatus
End If
Exit Sub
HandleErr:
If Err = 2220 Then
‘[imgPicture].Picture = “”
SysCmd acSysCmdSetStatus, “Can’t open image: ‘” & [PicFile] & “‘”
Else
MsgBox Err.Description, vbExclamation
End If
End SubPrivate Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyF5 Then Call cmdClose_Click
If KeyCode = vbKeyF3 Then Call cmdInsertPic_Click
If KeyCode = vbKeyF6 Then Call cmdPreview_Click
If KeyCode = vbKeyF2 Then Call Command64_Click
If KeyCode = vbKeyDelete Then Call cmdErasePic_Click
End SubPrivate Sub Form_Open(Cancel As Integer)
DoCmd.Close acForm, “frmCreateEstimate”, acSaveYes
If Me.RecordsetClone.RecordCount = 0 Then
MsgBox “You Have No Current Images For This File, Press OK”
Me.lstPreviewJpgs.SetFocus
End If
End SubPrivate Sub Command55_Click()
‘Opens the report
On Error GoTo Err_Command55_Click
Dim stDocName As String
stDocName = “Image Thumbs”
DoCmd.OpenReport stDocName, acNormal
Exit_Command55_Click:
Exit Sub
Err_Command55_Click:
MsgBox Err.Description
Resume Exit_Command55_Click
End SubPrivate Sub lstPreviewJpgs_AfterUpdate()
Me!PreviewOLE.Picture = “L:Home” & Me!lstPreviewJpgs
Forms!frmImages.SetFocus
Forms!frmImages.lstPreviewJpgs.SetFocus
End SubPrivate Sub lstPreviewJpgs_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
DoCmd.GoToRecord , , acNewRec
Me.EstimateNo = Forms!frmDetails!EstimateNo
Me.supp = Forms!frmDetails!supp
Me.txtRegistration = Forms!frmDetails!Registration
Me.PicFile = “L:Home” & Me.lstPreviewJpgs
Me.[imgPicture].Picture = [PicFile]
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Forms!frmImages.SetFocus
Forms!frmImages.lstPreviewJpgs.SetFocus
Else
End If
On Error GoTo errtrap
If KeyCode = vbKeyPageUp Then Me.txtRegistration.SetFocus
If KeyCode = vbKeyPageUp Then DoCmd.GoToRecord , , acPrevious
If KeyCode = vbKeyPageDown Then Me.txtRegistration.SetFocus
If KeyCode = vbKeyPageDown Then DoCmd.GoToRecord , , acNext
errtrap:
Exit Sub
End Sub
——————————————–
——————————————–This really stumping me.
Dave -
WSD Willett
AskWoody LoungerYou know.
I could sit for hours just posting these little glitches.
Hope to be of service to others at some time.
Thanks Francois.Dave
-
WSD Willett
AskWoody LoungerI have this on each field in the form.
I’ve also tried tried this cursor behaviour from options but don’t like how it re-acts in certain places.
Wonder if there is a remedy without using Keycode=vbkeyup / downDave
-
WSD Willett
AskWoody LoungerI have codes in the key events on both forms but I think this is causing the prob: –
me!Whatever.selStart = me!Whatever.selLength ??????
In the on_enter of the field
Dave
-
WSD Willett
AskWoody LoungerSlightly different but it now works
If KeyCode = vbKeyReturn Then
DoCmd.GoToRecord , , acNewRec
Me.EstimateNo = Forms!frmdetails!EstimateNo
Me.supp = Forms!frmdetails!supp
Me.txtRegistration = Forms!frmdetails!Registration
Me.PicFile = “L:Home” & Me.lstPreviewJpgs
‘Me.PicFile = Me.lstPreviewJpgsMe.[imgPicture].Picture = [PicFile]
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Forms!frmImages.SetFocus
Forms!frmImages.lstPreviewJpgs.SetFocus
ElseThanks.
Dave -
WSD Willett
AskWoody LoungerIf KeyCode = vbKeyReturn Then
DoCmd.GoToRecord , , acNewRec
Me.EstimateNo = Forms!frmdetails!EstimateNo
Me.supp = Forms!frmdetails!supp
Me.txtRegistration = Forms!frmdetails!Registration
Me.PicFile = Me.lstPreviewJpgs
Me.[imgPicture].Picture = [PicFile]
Me.lstPreviewJpgs.SetFocusI use this on keydown with the list.
The problem is [PicFile] is a field on my form and requires the full path to allow [imgPicture] to work correctly.
At the moment lstPreviewJpgs will return (example) 123.jpg to [picfile] instead of L:Home123.jpg
Can any-one help with this.
Dave
-
WSD Willett
AskWoody LoungerThanks all for the help, I found this ( directed from world forums) ( Thanks cpod ) but haven’t tried it yet.
I’ll let you know how things go.Dave
http://www.wopr.com/cgi-bin/w3t/showflat.p…;o=0&fpart=[/url]
Edited by Charlotte to activate link
-
WSD Willett
AskWoody LoungerThanks for that, Perfect
Dave
-
WSD Willett
AskWoody LoungerI am using A2000 and have implemented this code and procedure for exactly the same procedure.
My list box fills with the JPG names from my designated folder, all ok.When I click in the list box though, I get run-time 438 error.
I’ve had this prob before in other forms and stuff and been able to fix it.However, I cannot find the problem in this instance. I presume it is the difference in A97 & A2000.
How can I remedy this 438 fault.
Dave
-
WSD Willett
AskWoody LoungerHans
I’ve searched and none of the examples really meet my needs.
Not heard of the callback function before.My Images are located on L:Home???.jpg
Could you explain a little more in depth.
Dave
-
WSD Willett
AskWoody LoungerPerhaps the custom form is the better option for me, not sure what would happen on a run-time if word wasn’t on the pc.
Any directions in creating this form would be appreciated.
I do not store the images via OLE only the path.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
-
Installer program can’t read my registry
by
Peobody
3 hours, 3 minutes ago -
How to keep Outlook (new) in off position for Windows 11
by
EspressoWillie
5 hours, 12 minutes ago -
Intel : CVE-2024-45332, CVE-2024-43420, CVE-2025-20623
by
Alex5723
2 hours, 56 minutes ago -
False error message from eMClient
by
WSSebastian42
2 hours, 51 minutes ago -
Awoke to a rebooted Mac (crashed?)
by
rebop2020
11 hours, 55 minutes ago -
Office 2021 Perpetual for Mac
by
rebop2020
13 hours, 8 minutes ago -
AutoSave is for Microsoft, not for you
by
Will Fastie
4 hours, 27 minutes ago -
Difface : Reconstruction of 3D Human Facial Images from DNA Sequence
by
Alex5723
16 hours, 39 minutes ago -
Seven things we learned from WhatsApp vs. NSO Group spyware lawsuit
by
Alex5723
2 hours, 40 minutes ago -
Outdated Laptop
by
jdamkeene
22 hours, 5 minutes ago -
Updating Keepass2Android
by
CBFPD-Chief115
1 day, 3 hours ago -
Another big Microsoft layoff
by
Charlie
1 day, 3 hours ago -
PowerShell to detect NPU – Testers Needed
by
RetiredGeek
6 hours, 35 minutes ago -
May 2025 updates are out
by
Susan Bradley
2 hours, 29 minutes ago -
Windows 11 Insider Preview build 26200.5600 released to DEV
by
joep517
1 day, 9 hours ago -
Windows 11 Insider Preview build 26120.3964 (24H2) released to BETA
by
joep517
1 day, 9 hours ago -
Drivers suggested via Windows Update
by
Tex265
1 day, 9 hours ago -
Thunderbird release notes for 128 esr have disappeared
by
EricB
1 day, 6 hours ago -
CISA mutes own website, shifts routine cyber alerts to X, RSS, email
by
Nibbled To Death By Ducks
1 day, 16 hours ago -
Apple releases 18.5
by
Susan Bradley
1 day, 10 hours ago -
Fedora Linux 40 will go end of life for updates and support on 2025-05-13.
by
Alex5723
1 day, 17 hours ago -
How a new type of AI is helping police skirt facial recognition bans
by
Alex5723
1 day, 18 hours ago -
Windows 7 ISO /Windows 10 ISO
by
ECWS
2 hours, 33 minutes ago -
No HP software folders
by
fpefpe
2 days, 1 hour ago -
Which antivirus apps and VPNs are the most secure in 2025?
by
B. Livingston
23 hours, 10 minutes ago -
Stay connected anywhere
by
Peter Deegan
2 days, 7 hours ago -
Copilot, under the table
by
Will Fastie
9 hours, 38 minutes ago -
The Windows experience
by
Will Fastie
2 days, 13 hours ago -
A tale of two operating systems
by
Susan Bradley
17 hours, 41 minutes ago -
Microsoft : Resolving Blue Screen errors in Windows
by
Alex5723
2 days, 18 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.