Results 1 to 7 of 7
  1. #1
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Update Records in A Datasheet? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    I have a Main Form with a Datasheet Sub Form that contains queried records.

    I want a button on the Main Form I can click and in code have just the queried records in the Datasheet Sub Form updated field strPrintFlag with an

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Update Records in A Datasheet? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    What do you mean by 'queried'? That the user has applied a filter?

  3. #3
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Update Records in A Datasheet? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    On the Main Form using a unbound Text Box and Command button that generates the following SQL:

    Select * from qrytbl_RPS_Owner Where [strLocStreetNameNo] Like 'ap*' ORDER By strLocStreetNameNo ASC;

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Update Records in A Datasheet? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    You can generate the following SQL string and execute it:
    <code>
    Dim strSQL As String
    strSQL = "UPDATE qrytbl_RPS_Owner SET strPrintFlag = 'A' WHERE [strLocStreetNameNo] Like 'ap*'"
    ' Use only one of the following lines. Either
    DoCmd.RunSQL strSQL, True
    ' Or
    CurrentDb.Execute strSQL, dbFailOnError
    ' Not both!
    </code>
    You may have to requery the subform to show the updated values.

  5. #5
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Update Records in A Datasheet? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    Thanks Hans

    That works.

    Is there a way to step through the current record set with the same strPrintFlag =

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Update Records in A Datasheet? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    You could open a recordset rst based on the SELECT SQL, and use rst.Edit ... rst.Update, but that is much less efficient than running the UPDATE SQL.

  7. #7
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Update Records in A Datasheet? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •