RunCommand not working

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

The following code has been working fine for weeks. The past couple of days, I get an error "command 'RecordsGoToNew' isn't available now" when I run this. I checked the enabled references and made sure that MS ActiveX Data objects 2.8 is active which it is. I don't get a compile error with this line. Any suggestions appreciated. Here is my code:
The ">" is added to highlight the malfunctioning line

With Me.frmPatPhoneSub.For

.AllowAdditions = Tru
Me.frmPatPhoneSub.SetFocu
RunCommand acCmdRecordsGoToNe

.PatientID = Me.PatientI
.PhoneID = InsertPhoneRecord(
Me.Dirty = Fals
.AllowAdditions = Fals
.Requer
RunCommand acCmdRecordsGoToLas

End With
 
Instead of these:
RunCommand acCmdRecordsGoToNew
RunCommand acCmdRecordsGoToLast


try these:

DoCmd.RunCommand acCmdRecords acCmdRecordsGoToNew
DoCmd.RunCommand acCmdRecords acCmdRecordsGoToLast


hth,

--

Cheryl Fischer, MVP Microsoft Access
Law/Sys Associates, Houston, TX


smk2 said:
The following code has been working fine for weeks. The past couple of
days, I get an error "command 'RecordsGoToNew' isn't available now" when I
run this. I checked the enabled references and made sure that MS ActiveX
Data objects 2.8 is active which it is. I don't get a compile error with
this line. Any suggestions appreciated. Here is my code:
 
I tried
DoCmd.RunCommand acCmdRecordsGoToNe
(syntax error with the "acCmdRecords" in the line

with the same error message returned.
?
 
okay, sleuthing this out, this is what I've discovered

if this is the first record to add, the following line works fine
this was my previous code a few weeks ago, but changed because it worked erratically

DoCmd.GoToRecord , , acNewRe

if there are no records, the following line will fail (but not the former)

RunCommand acCmdRecordsGoToNe

So it would appear that there is some instability within Access itself
Any comments
Thank
SMK
 
smk2 said:
okay, sleuthing this out, this is what I've discovered:

if this is the first record to add, the following line works fine:
this was my previous code a few weeks ago, but changed because it worked erratically.

DoCmd.GoToRecord , , acNewRec

if there are no records, the following line will fail (but not the former):

RunCommand acCmdRecordsGoToNew

So it would appear that there is some instability within Access itself.


Try Checking if you're already on the new record before
trying to go to it.

If Not Me.NewRecord Then
DoCmd.GoToRecord , , acNewRec
End If
 
Back
Top