Results 1 to 3 of 3
  1. #1
    jo15765's Avatar
    jo15765 is offline Expert
    Windows XP Access 2000
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    672

    rs.EOF Meaning

    I understand that this piece of syntax has a select statement and it is set to run the select statement. BUT, I want to granularly break it down a step further and fully understand what each line is doing. Is their a check in place that checks if the data already exists?


    Code:
    queryTorun = "Select userID, Salesmanager from tableSalesInfo where userid = '" & textbox1 & "' AND Salesmanager = '" & textbox2 & "';"
    Set rs = dbConn.Execute(queryTorun)
    If (rs.EOF) Then
      dbConn.Execute ("Insert Into tableSalesInfo Values ('" & textbox1 & "', '" & textbox2 & "');")
    End If

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    The EOF line checks to see whether any records were returned.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    If you are using DAO, the code snippet won't (shouldn't) execute.

    "EOF" means End of File, ie past the last record in the recordset. If no records are returned, then .BOF will be TRUE and .EOF will be TRUE.

    In this line,
    Code:
    Set rs = dbConn.Execute(queryTorun)
    "Execute" is for action queries ("Insert INTO", "Delete"), not "Select" statements.


    I would use
    Code:
    Set rs = dbConn.OpenRecordset(queryTorun)



    This line
    Code:
    dbConn.Execute ("Insert Into tableSalesInfo Values ('" & textbox1 & "', '" & textbox2 & "');")
    tells me that there are only two field in the table because the field names are not in the statement.
    Normally the statement would be
    Code:
    dbConn.Execute ("Insert Into tableSalesInfo( userid, Salesmanager) Values ('" & textbox1 & "', '" & textbox2 & "');")
    Remember, I am talking about DAO. I don't use ADO.


    My $0.02.....

Please reply to this thread with any new information or opinions.

Similar Threads

  1. What is the meaning of this query?
    By doci4a in forum Queries
    Replies: 2
    Last Post: 03-15-2011, 07:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums