Re: recordcount gives back -1...

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



I have already done this..and it doesn't work!!
That's really strange. Isn't it?

Thanks anyway

"Douglas J. Steele" wrote:

rst.Open "SELECT * FROM " & tbll.Name & " WHERE CODRATER=" &
Forms(ff.Name).Controls("CERCA").Value, CurrentProject.Connection,
adOpenDynamic, adLockOptmistic
rst.MoveLast
rst.MoveFirst
If rst.RecordCount > 0 Then


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"rocco" <rocco@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:02BF10AF-FDB1-499D-9CB3-B1E227CCC560@xxxxxxxxxxxxxxxx
Hello,
I have code (posted below) which needs to evaluate the numbers of records
entered for each rater of a questionnaire. I can have a maximum of 50
raters.
each rater has a code going from 1 to 50.

But when I evaluate the recordcount property in the code below i always
get
a -1 and the code that should be run is skipped...
Here is the code:

Public Sub Salva(tbll As TableDef, ff As Form)
Dim i As Integer
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
If GeneralCheck(ff) = True Then
If finderlet = True Then
MsgBox tbll.Name
MsgBox tbll.RecordCount
rst.Open "SELECT * FROM " & tbll.Name & " WHERE CODRATER=" &
Forms(ff.Name).Controls("CERCA").Value, CurrentProject.Connection,
adOpenDynamic, adLockOptmistic
If rst.RecordCount > 0 Then
For i = 0 To rst.Fields.Count - 2
rst.Fields(i).Value =
IIf(IsNull(Forms(ff.Name).Section(acDetail).Controls(rst.Fields(i).Name).Value),
Null, Forms(ff.Name).Section(acDetail).Controls(rst.Fields(i).Name).Value)
Next i
rst.Update
End If
MsgBox "Dati aggiornati!", vbInformation, "Registrazione
effettuata"
(follow other code...)

Any hint?
Thanks,
Rocco



.



Relevant Pages

  • Re: recordcount gives back -1...
    ... entered for each rater of a questionnaire. ... But when I evaluate the recordcount property in the code below i always ... Dim rst As ADODB.Recordset ... MsgBox tbll.RecordCount ...
    (microsoft.public.access.modulesdaovba)
  • Re: Check for Null in Table
    ... "Douglas J. Steele" wrote: ... MsgBox "One or more rows have Null in them. ... Doug Steele, Microsoft Access MVP ... any subform. ...
    (microsoft.public.access.forms)
  • Re: Relinking Tables with VBA code
    ... Doug Steele, Microsoft Access MVPhttp://I.Am/DougSteele ... Usually the backend is always in the same ... MsgBox but after that it links only the first table but not ... Dim strPath As String ...
    (microsoft.public.access.formscoding)
  • Re: Compile Error Help
    ... I'm sure declaring the variable as Integer would ... > Doug Steele, Microsoft Access MVP ... A2003 Help says that the MsgBox() function returns an Integer ... >>> Doug Steele, Microsoft Access MVP ...
    (microsoft.public.access.formscoding)
  • Re: manditory field
    ... MsgBox ... Private Sub Form_Unload ... Doug Steele, Microsoft Access MVP ... query and form but the user still can exit the form without entering data. ...
    (microsoft.public.access.formscoding)