Trying to convert a SendKey command to something "newer"

ncbeachbum

New member
Local time
Today, 10:46
Joined
Jul 12, 2015
Messages
4
We have a ton of Access 97 DBs I've been asked to "fix". Since moving to Windows 7 some of them have been giving Error70 comands, which I've narrowed down to Sendkey not playing nicely with Windows 7. Anyway, I was able to fix it for one user by turning UAC off. Not my preferred way to operate, but it's a stopgap until I can get this mess sorted out.

Ok, here's the code. This is an event procedure that is tied to a date field where staff are to enter a date in MM/DD/YYYY format. For some reason there is no tab order anywhere on this DB so they have to click to enter. In the past they had to make sure that they clicked at the left most M in MM to make the entry.

It appears that this Sendkey is the culprit here. Is there anyway I can safely remove that w/o breaking something? I cannot get sole access to this DB as it's in use pretty much 24/7 until the 11pm backup for the server it resides on. It is Access 97. I was thinking of just pulling the macro from that field but then again I am not an Access person by any means, just someone asked to try and fix it while they hunt for a replacement (the DBA who had been here left on short notice).

[FONT=&quot] Option Compare Database[/FONT]
[FONT=&quot] Option Explicit[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot] Private Sub cboxptno_GotFocus()[/FONT]
[FONT=&quot] cboxptno.Dropdown[/FONT]
[FONT=&quot] End Sub[/FONT]
[FONT=&quot] ----[/FONT]
[FONT=&quot] Private Sub Command111_Click()[/FONT]
[FONT=&quot] On Error GoTo Err_Command111_Click[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot] DoCmd.Close[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot] Exit_Command111_Click:[/FONT]
[FONT=&quot] Exit Sub[/FONT]
[FONT=&quot] ---[/FONT]
[FONT=&quot] Err_Command111_Click:[/FONT]
[FONT=&quot] MsgBox Err.Description[/FONT]
[FONT=&quot] Resume Exit_Command111_Click[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot] End Sub[/FONT]
[FONT=&quot] ---[/FONT]
[FONT=&quot] Private Sub needdate_Click()[/FONT]
[FONT=&quot] Dim intWait As Integer[/FONT]
[FONT=&quot] Dim intCount As Integer[/FONT]
[FONT=&quot] If IsNull(Me![needdate]) Then[/FONT]
[FONT=&quot] SendKeys "{Home}"[/FONT]
[FONT=&quot] Else[/FONT]
[FONT=&quot] intWait = 1000[/FONT]
[FONT=&quot] For intCount = 1 To intWait[/FONT]
[FONT=&quot] DoEvents[/FONT]
[FONT=&quot] Next[/FONT]
[FONT=&quot] SendKeys "{Home}"[/FONT]
[FONT=&quot] End If[/FONT]
[FONT=&quot] End Sub[/FONT]
[FONT=&quot] ----[/FONT]
[FONT=&quot] Private Sub reqdate_BeforeUpdate(Cancel As Integer)[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot] End Sub[/FONT]
 
Deep doo doo, me thinks :D

But just hung in there, and bump your post at about 5 PM GMT, if no other replies have appeared by that time.
 
Deep doo doo, me thinks :D

Yeah, I'm starting to think that. I've been able to upgrade some DBs to 2003, but the bulk of the other databases all tie into one large DB. Patient info, financial info (not related to patients, etc), all tie into one. It's crazy. No idea why the guy who was here before did things like that but it makes no sense.

Time to hammer on tutorials and cross my fingers that nothing breaks. :)
 
What is the SendKeys doing? Would setting focus to a control or record be a replacement?

Also concerned that you can't get access. The db should be split, and you'd be able to work on a new front end without worrying about users.
 
It sounds like some business-critical monster application. Get a pro Access-tinkerer to help.
 
Error 70 is a permission denied error so I'm doubtful that it's related to SendKeys.

Comment out all the "On Error GoTo ..." lines, re-run whatever process that throws the error, and tell us which code line it highlights.

You can take a copy of the front end and test it on your machine.
 
a) what does SendKeys "{Home}" do? Can that be removed temporarily.?

b) I didn't think A97 would run on W7. How are you getting it to work at all? And later versions of Access beyond A2003 won't read A97 code.

c) ^ what PBaldy said about splitting the DBS.
 
You can use .SelStart and .SelLength to position the cursor at the start of the control.

Wayne
 
b) I didn't think A97 would run on W7. How are you getting it to work at all? And later versions of Access beyond A2003 won't read A97 code.

c) ^ what PBaldy said about splitting the DBS.

b) It can. If you have Office 2013 on the box and install 97, it removes A2013. Sometimes A13 will "return", but by doing a repair install on A97 all is well again.

c) I just checked it is split. Found some notes last night, going to try and read them this morning.
 
I see. I gave up on the venerable A97, and converted wholly to A2003.

https://social.technet.microsoft.co...nstall-access-97-and-office-2007-on-windows-7

Personally, I would be inclined to move the dbs from A97 to A2003, and then run them in whatever version of access the users have. I would not remove A2013 to try and install A97, even if possible. A2013 will peacefully co-exist with A2003, and will run any A2003 database.

----
for {home} try the runcommand actions. If there is a replacement for sendkeys "{home}", I am sure it will be one of those.
 

Users who are viewing this thread

Back
Top Bottom