W
Waddle
I am currently working on an access db. The problem I am having is that I
have a main form with a subform. There is a combo box that has a list of
routes that we use. When you select the route you want it is supposed to
bring up the customer info that pertains to that particular route. In the
code the is a runcommand that directs to the next record. When I step
through the code and get to this part of the code it says 'Command or action
"RecordGoToNext" is not available now'. Can anyone help? Here is the code
for the section I am having trouble with:
Private Sub cboStaticRtes_AfterUpdate()
On Err GoTo err_cboStaticRtes_AfterUpdate
Dim rstStaticRte As New ADODB.Recordset
Dim objCmd As New ADODB.Command
Dim objParm1 As New ADODB.Parameter
Dim intSlot As Integer
intSlot = 1
Select Case Me.txtOprId.Value
Case "NASUNI"
objCmd.CommandText = "procStaticRte"
Case "TAMSON"
objCmd.CommandText = "procStaticRteS1"
Case "BIRSON"
objCmd.CommandText = "procStaticRteS1"
Case "HOUUNI"
objCmd.CommandText = "procStaticRteHou"
End Select
objCmd.CommandType = adCmdStoredProc
objCmd.ActiveConnection = CurrentProject.Connection
Debug.Print objCmd.ActiveConnection
objCmd.Parameters.Refresh
objCmd(1) = Me.cboStaticRtes.Value
Set rstStaticRte = objCmd.Execute
If Not (rstStaticRte.BOF = True) Then
rstStaticRte.MoveFirst
Else
Exit Sub
End If
Do Until rstStaticRte.EOF = True
Me.tblStopssubform.Form!StopAddress = rstStaticRte.Fields("Address").Value
Me.tblStopssubform.Form!StopTermCust =
rstStaticRte.Fields("BusinessName").Value
Me.tblStopssubform.Form!StopCity = rstStaticRte.Fields("City").Value
Me.tblStopssubform.Form!StopState = rstStaticRte.Fields("ST").Value
Me.tblStopssubform.Form!StopZip = rstStaticRte.Fields("Zip").Value
Me.tblStopssubform.Form!StopApptSchedule =
rstStaticRte.Fields("StdDlvTime").Value
Me.tblStopssubform.Form!SlotNum = intSlot
tblStopssubform.SetFocus
DoCmd.RunCommand acCmdRecordsGoToNext
intSlot = intSlot + 1
rstStaticRte.MoveNext
Loop
'clean up
rstStaticRte.Close
Set rstStaticRte = Nothing
Set objParm1 = Nothing
Set objCmd = Nothing
exit_cboStaticRtes_AfterUpdate:
Exit Sub
err_cboStaticRtes_AfterUpdate:
MsgBox "Error has occured --->" & Err.Description
'Clean up
rstStaticRte.Close
Set rstStaticRte = Nothing
Set objParm1 = Nothing
Set objCmd = Nothing
Resume exit_cboStaticRtes_AfterUpdate
End Sub
Thanks in advance!!!!!!!!!!!!!!
have a main form with a subform. There is a combo box that has a list of
routes that we use. When you select the route you want it is supposed to
bring up the customer info that pertains to that particular route. In the
code the is a runcommand that directs to the next record. When I step
through the code and get to this part of the code it says 'Command or action
"RecordGoToNext" is not available now'. Can anyone help? Here is the code
for the section I am having trouble with:
Private Sub cboStaticRtes_AfterUpdate()
On Err GoTo err_cboStaticRtes_AfterUpdate
Dim rstStaticRte As New ADODB.Recordset
Dim objCmd As New ADODB.Command
Dim objParm1 As New ADODB.Parameter
Dim intSlot As Integer
intSlot = 1
Select Case Me.txtOprId.Value
Case "NASUNI"
objCmd.CommandText = "procStaticRte"
Case "TAMSON"
objCmd.CommandText = "procStaticRteS1"
Case "BIRSON"
objCmd.CommandText = "procStaticRteS1"
Case "HOUUNI"
objCmd.CommandText = "procStaticRteHou"
End Select
objCmd.CommandType = adCmdStoredProc
objCmd.ActiveConnection = CurrentProject.Connection
Debug.Print objCmd.ActiveConnection
objCmd.Parameters.Refresh
objCmd(1) = Me.cboStaticRtes.Value
Set rstStaticRte = objCmd.Execute
If Not (rstStaticRte.BOF = True) Then
rstStaticRte.MoveFirst
Else
Exit Sub
End If
Do Until rstStaticRte.EOF = True
Me.tblStopssubform.Form!StopAddress = rstStaticRte.Fields("Address").Value
Me.tblStopssubform.Form!StopTermCust =
rstStaticRte.Fields("BusinessName").Value
Me.tblStopssubform.Form!StopCity = rstStaticRte.Fields("City").Value
Me.tblStopssubform.Form!StopState = rstStaticRte.Fields("ST").Value
Me.tblStopssubform.Form!StopZip = rstStaticRte.Fields("Zip").Value
Me.tblStopssubform.Form!StopApptSchedule =
rstStaticRte.Fields("StdDlvTime").Value
Me.tblStopssubform.Form!SlotNum = intSlot
tblStopssubform.SetFocus
DoCmd.RunCommand acCmdRecordsGoToNext
intSlot = intSlot + 1
rstStaticRte.MoveNext
Loop
'clean up
rstStaticRte.Close
Set rstStaticRte = Nothing
Set objParm1 = Nothing
Set objCmd = Nothing
exit_cboStaticRtes_AfterUpdate:
Exit Sub
err_cboStaticRtes_AfterUpdate:
MsgBox "Error has occured --->" & Err.Description
'Clean up
rstStaticRte.Close
Set rstStaticRte = Nothing
Set objParm1 = Nothing
Set objCmd = Nothing
Resume exit_cboStaticRtes_AfterUpdate
End Sub
Thanks in advance!!!!!!!!!!!!!!