RunCommand acCmdRecordsGoToNext

Tech-Archive recommends: Speed Up your PC by fixing your registry



Hi,

I am trying to use the following statement in VBA in order to change
information in all records of a database.

RunCommand acCmdRecordsGoToNext

On random occasions, I get the following message
"The command or action RecordsGoToNext isn't available now"

I have done some research, and have absorbed as much information as I
can find, but haven't had any success. I have run this code on
numerous occasions without issue, and have run it on numerous occasions
with an issue. All the data has been static and unchanged. I have
seen many statements of "There is a field where you data is incorrect
and cannot move to a different record", however, this holds untrue in
this instance. Below is the entire syntax in which I am using this
command.

Please note, I do have buttons that allow me to navigate through
records (using DoCmd.GoToRecord,, acNext), and even after the loop has
failed, these buttons work without a hitch. Again, I'm not sure why it
is simply an issue here. I have also attempted the DoCmd.GoToRecord ,
, acNext rather than the RunCommand method in the code below. Any help
in this matter would be greatly appreciated.

Private Sub RemoveChanges_Click()
Dim intRecordCount As Integer
Dim strPassword As String
Dim strPasswordConfirm As String

'Go to first record so that record count for
'While Loop is correct, and extra
'records are not created.
RunCommand acCmdRecordsGoToFirst

strPassword = "YEROC"

strPasswordConfirm = InputBox("Please enter the password to confirm,
otherwise press cancel to exit without changes:", "Confirm Erase all
Change Tracking")

On Error GoTo Err_RemoveChanges_Click

If strPassword = strPasswordConfirm Then

intRecordCount = 1
While intRecordCount <= RecordsetClone.RecordCount
chgCHG = False
chgStore = False
chgProjectType = False
chgGRP = False
chgGMP = False
chgRCM = False
chgCity = False
chgState = False
chgCluster = False
chgMostRecentActivityNotice = False
chgMostRecentPlanDistribution = False
chgTwelveWeeksBeforeFixtureDate = False
chgEightWeeksBeforeDryRunDate = False
chgFixtureDate = False
chgMerchandiseStartDate = False
chgStatus = False
chgDryRunDateorCompletionDate = False
chgGrandOpeningDate = False
chgProjectTypeandCtn = False
chgCompletedLayoutType = False
chgComments = False
chgInteriorSigns = False
chgExteriorSigns = False
chgLeasedOwned = False
chgProjectNumber = False

RunCommand acCmdRecordsGoToNext <--- this is the point where the
code breaks

intRecordCount = intRecordCount + 1
Wend

RunCommand acCmdRecordsGoToFirst

Else
MsgBox ("You have cancelled the previous operation, or have entered
an incorrect password")
End If
Exit_RemoveChanges_Click:
Exit Sub

Err_RemoveChanges_Click:
MsgBox Err.Description
Resume Exit_RemoveChanges_Click
End Sub

Thanks!!

Keith

.


Quantcast