"No current record" error

  • Thread starter Thread starter wardcola
  • Start date Start date
W

wardcola

I've gone as far as I can using macros and such and VBA
seems my only solution. I am trying to update/add
records/modify field data in a subform. The primary form
uses a collection of data about a batcha of invoices to be
processed by one of our staff. Each batch of invoices
automatically receives a contol number. The subform is to
record specific invoices or items from invoices that can't
be processed for reasons sucha s incorrect billing amounts
or other data. Each subform record contains the Batch
control number and links to the primary form in a one to
many relationship. What I am trying to do is
1. make the subform visible based on the value in a field
in the primary (#problems). If the value is null or 0,
the subform does not show.
2. If the value of (#Problems) is greater than 0 the
subform shows and the user can add records to the subform
recordset up to the value in the (#Problems) field.
3. Also field values in the primary form will be updated
based on record information entered into the subform.

I keep getting the error "No current Record" at the
statement, "rstProb.Edit"

Thanks for any and all ideas. Here is my code.


Private Sub Form_Current()
Dim frmInv As Form
Dim frmProb As Form
Dim rstInv As Recordset
Dim rstProb As Recordset
Dim fldInvNumProbs As Field
Dim fldInvVendor As Field
Dim fldProbVendor As Field

Set frmInv = Forms!frmInvLog.Form
Set frmProb = frmInv!frmProb.Form
Set rstInv = frmInv.Recordset
Set rstProb = frmProb.Recordset
Set fldInvNumProbs = rstInv.Fields("[#Problems]")
Set fldInvVendor = rstInv.Fields("Vendor")
Set fldProbVendor = rstProb.Fields("Vendor")

If fldInvNumProbs.Value = 0 Or Null Then
frmProb.Visible = False
End

Else
frmProb.Visible = True
frmProb.Recordset.MoveFirst
Debug.Print frmProb.CurrentRecord

Debug.Print rstProb.Updatable
rstInv.Edit
rstInv.Update
Stop
frmProb.Controls("[Control Id#]") = frmInv.Controls
("[Control Id#]")
Debug.Print frmProb.Form.CurrentRecord

rstProb.Edit
fldProbVendor = fldInvVendor
rstProb.Update

End If

'Stop
End Sub

Private Sub Form_DataChange(ByVal Reason As Long)

Dim frmInv As Form
Dim frmProb As Form
Dim rstInv As Recordset
Dim rstProb As Recordset
Dim fldInvNumProbs As Field

Set frmInv = Forms!frmInvLog.Form
Set frmProb = frmInv!frmProb.Form
Set rstInv = frmInv.Recordset
Set rstProb = frmProb.Recordset
Set fldInvNumProbs = rstInv.Fields("[#Problems]")

If fldInvNumProbs.Value = 0 Or Null Then
frmProb.Visible = False
Else
frmProb.Visible = True
End If
Stop

End Sub
 
You're setting rstProb to be the form's recordset, but then you do the
MoveFirst on the form's recordset, not on rstProb. Use rstProb in the
MoveFirst command.
 
Thanks Ken. I'll give that a go. Four new books, hours
upon hours of study, no result. I really appreciate your
response.
-----Original Message-----
You're setting rstProb to be the form's recordset, but then you do the
MoveFirst on the form's recordset, not on rstProb. Use rstProb in the
MoveFirst command.

--
Ken Snell
<MS ACCESS MVP>

I've gone as far as I can using macros and such and VBA
seems my only solution. I am trying to update/add
records/modify field data in a subform. The primary form
uses a collection of data about a batcha of invoices to be
processed by one of our staff. Each batch of invoices
automatically receives a contol number. The subform is to
record specific invoices or items from invoices that can't
be processed for reasons sucha s incorrect billing amounts
or other data. Each subform record contains the Batch
control number and links to the primary form in a one to
many relationship. What I am trying to do is
1. make the subform visible based on the value in a field
in the primary (#problems). If the value is null or 0,
the subform does not show.
2. If the value of (#Problems) is greater than 0 the
subform shows and the user can add records to the subform
recordset up to the value in the (#Problems) field.
3. Also field values in the primary form will be updated
based on record information entered into the subform.

I keep getting the error "No current Record" at the
statement, "rstProb.Edit"

Thanks for any and all ideas. Here is my code.


Private Sub Form_Current()
Dim frmInv As Form
Dim frmProb As Form
Dim rstInv As Recordset
Dim rstProb As Recordset
Dim fldInvNumProbs As Field
Dim fldInvVendor As Field
Dim fldProbVendor As Field

Set frmInv = Forms!frmInvLog.Form
Set frmProb = frmInv!frmProb.Form
Set rstInv = frmInv.Recordset
Set rstProb = frmProb.Recordset
Set fldInvNumProbs = rstInv.Fields("[#Problems]")
Set fldInvVendor = rstInv.Fields("Vendor")
Set fldProbVendor = rstProb.Fields("Vendor")

If fldInvNumProbs.Value = 0 Or Null Then
frmProb.Visible = False
End

Else
frmProb.Visible = True
frmProb.Recordset.MoveFirst
Debug.Print frmProb.CurrentRecord

Debug.Print rstProb.Updatable
rstInv.Edit
rstInv.Update
Stop
frmProb.Controls("[Control Id#]") = frmInv.Controls
("[Control Id#]")
Debug.Print frmProb.Form.CurrentRecord

rstProb.Edit
fldProbVendor = fldInvVendor
rstProb.Update

End If

'Stop
End Sub

Private Sub Form_DataChange(ByVal Reason As Long)

Dim frmInv As Form
Dim frmProb As Form
Dim rstInv As Recordset
Dim rstProb As Recordset
Dim fldInvNumProbs As Field

Set frmInv = Forms!frmInvLog.Form
Set frmProb = frmInv!frmProb.Form
Set rstInv = frmInv.Recordset
Set rstProb = frmProb.Recordset
Set fldInvNumProbs = rstInv.Fields("[#Problems]")

If fldInvNumProbs.Value = 0 Or Null Then
frmProb.Visible = False
Else
frmProb.Visible = True
End If
Stop

End Sub


.
 
Back
Top