[AccessD] Help with syntax please....OpenRecordset

StaRKeY starkey at wanadoo.nl
Thu Oct 14 11:17:18 CDT 2004


Mmmzzz don't wanna be fuzzy but one remark about the codesample though just
in case others wanna use it... To use a recordcount if I remember well, you
should always do a rs.movelast and a rs.movefirst first to populate the
recordset and get a reliable recordcount.

Regards, 
Eric Starkenburg 

-----Oorspronkelijk bericht----- 
Van: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] Namens Kath Pelletti 
Verzonden: woensdag 13 oktober 2004 05:08 
Aan: Access Developers discussion and problem solving 
Onderwerp: Re: [AccessD] Help with syntax please....OpenRecordset 

Thanks Vlad - I thought that was the problem too....but it seems that it
just doesn't like my query even though the query runs fine in the normal
access window. 

I may have to change it to an sql statement. Sigh - I had already tried that
this morning but just couldn't get the syntax right ....

I will have another go at the sql syntax and if I can't nail it post back. 

Thanks 
Kath 
  ----- Original Message ----- 
  From: ACTEBS 
  To: Access Developers discussion and problem solving 
  Sent: Wednesday, October 13, 2004 12:50 PM 
  Subject: RE: [AccessD] Help with syntax please....OpenRecordset 


  Kath, 

  Maybe like this: 

  Dim strerrormsg, strsql, StrQueryName As String 
  Dim VarEmailto As Variant 
  Dim intrecno, IntWebLetterID As Integer 
  Dim db As DAO.Database '>>>>>>>>>I changed this 
  Dim rs As DAO.Recordset 

  Set db = CurrentDb 


  StrQueryName = "QryWebLetter_ReadRecipientsEmail" 
    
  Set rs = db.OpenRecordset(StrQueryName, dbOpenDynaset)     ' Open 
  recordset on saved query        ERROR HERE 

  '>>>>>>>>>>>>>>Made a few changes here 
  If rs.recordcount > 0 then 
  Rs.movefirst 
  Do Until rs.EOF 
  With rs 
      .Edit 
       VarEmailto = .Fields("LoginEmail") 
          .Update 
  End With 
  rs.movenext 
  loop 
  End if 

  'MsgBox ("Going to " & VarEmailto) 

  'Call Send_Email(VarEmailto, StrNamePDFFile) 

  Rs.close 
  Set rs = nothing 
  Db.close 
  Set db = nothing 

  HTH. You will need to check over it as I did it off the top of my head, 
  but you'll get the idea anyway... 

  Vlad 


  -----Original Message----- 
  From: accessd-bounces at databaseadvisors.com 
  [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Kath Pelletti 
  Sent: Wednesday, 13 October 2004 11:46 AM 
  To: AccessD at databaseadvisors.com 
  Subject: [AccessD] Help with syntax please....OpenRecordset 


  I am trying to use a saved query for my recordset source....but keep 
  getting an error 'Too few parameters - expected 1' on the line 'Set rs = 
  ' After many hours, I can't fix it so would appreciate the help..... 


  Code: 

  ------------------------------------------------------------------------ 
  -------- 

  Public Function EmailWebLetterRecipients() 
  Dim strerrormsg, strsql, StrQueryName As String 
  Dim VarEmailto As Variant 
  Dim intrecno, IntWebLetterID As Integer 
  Dim db As Database 
  Dim rs As DAO.Recordset 
  Set db = CurrentDb 


  StrQueryName = "QryWebLetter_ReadRecipientsEmail" 
    
  Set rs = db.OpenRecordset(StrQueryName, dbOpenDynaset)     ' Open 
  recordset on saved query        ERROR HERE 

  With rs 
      .MoveFirst 
      .Edit 

       VarEmailto = .Fields("LoginEmail") 
      .Update 
      .close 
  End With 
  'MsgBox ("Going to " & VarEmailto) 

  'Call Send_Email(VarEmailto, StrNamePDFFile) 

  Normal_exit: 
      DoCmd.SetWarnings True 
      Exit Function 

  Err_Handler: 
      MsgBox "Error: [" & Err.Number & "]  " & IIf(Len(strerrormsg) > 0, 
  strerrormsg, Err.Description), vbCritical, "Error Message" 
      Resume Normal_exit 
  End Function 


  ------------------------------------------------------------------------ 
  -------- 

  Kath Pelletti 
  Software Design & Solutions Pty Ltd. 
  Ph: 9505-6714 
  Fax: 9505-6430 
  KP at SDSOnline.net 
  -- 
  _______________________________________________ 
  AccessD mailing list 
  AccessD at databaseadvisors.com 
  http://databaseadvisors.com/mailman/listinfo/accessd 
  Website: http://www.databaseadvisors.com 
  -- 
  _______________________________________________ 
  AccessD mailing list 
  AccessD at databaseadvisors.com 
  http://databaseadvisors.com/mailman/listinfo/accessd 
  Website: http://www.databaseadvisors.com 
-- 
_______________________________________________ 
AccessD mailing list 
AccessD at databaseadvisors.com 
http://databaseadvisors.com/mailman/listinfo/accessd 
Website: http://www.databaseadvisors.com 



  _____  

avast! Antivirus <http://www.avast.com> : Uitgaande bericht is niet besmet. 


Virus Gegevensbestand (VPS): 0442-2, 14-10-2004
Getest op: 14-10-2004 18:17:18
avast! auteursrecht (c) 2000-2004 ALWIL Software.






More information about the AccessD mailing list