Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Feb 2004
    Location
    Moundridge, Kansas, USA
    Posts
    342
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Command Button to set Shipped Date (Access 2003/SP3)

    What is wrong with this code?

    Private Sub CmdShipped_Date_Click()
    On Error GoTo Err_CmdShipped_Date_Click

    Dim strSQL As String

    strSQL = "UPDATE tblOrders SET tblOrders.ShippedDate = [Enter date to set]" & _
    "WHERE tblOrders.OrderID = BETWEEN [Enter starting Order #] AND ([Enter ending order #]));"

    'Dim stDocName As String

    'stDocName = "qryupShippedDate"
    'DoCmd.OpenQuery stDocName, acNormal, acEdit

    Exit_CmdShipped_Date_Click:
    Exit Sub

    Err_CmdShipped_Date_Click:
    MsgBox Err.Description
    Resume Exit_CmdShipped_Date_Click

    End Sub

    I have a query that works, but I am trying to graduate to VBA coding for my SQL stuff. What I'm trying to do is set the shipped date on a set number of orders.

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

    Re: Command Button to set Shipped Date (Access 2003/SP3)

    There is a parenthesis too much and an incorrect = before BETWEEN, and there is no space before WHERE.
    To execute the SQL, you can use DoCmd.RunSQL.
    <code>
    strSQL = "UPDATE tblOrders SET ShippedDate = [Enter date to set] " & _
    "WHERE OrderID BETWEEN [Enter starting Order #] AND [Enter ending order #]"
    DoCmd.RunSQL strSQL</code>

  3. #3
    3 Star Lounger
    Join Date
    Feb 2004
    Location
    Moundridge, Kansas, USA
    Posts
    342
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Command Button to set Shipped Date (Access 200

    Thanks a million.

Posting Permissions

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