Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you will be running the query from within an Access application session, you can let the db engine use the Access expression service to grab the values from the text boxes on your form.</p> <pre class="lang-vb prettyprint-override"><code>Dim db As DAO.Database Dim strUpdate As String strUpdate = "UPDATE tblJob" &amp; vbCrLf &amp; _ "SET InvoiceNo = '" &amp; newInvoiceNo &amp; "'" &amp; vbCrLf &amp; _ "WHERE CustomerNo = '" &amp; VbCustNo &amp; "'" &amp; vbCrLf &amp; _ "AND FinishDate BETWEEN Forms!frmMainMenu!txtFirstDate AND Forms!frmMainmenu!txtEndDate;" Debug.Print strUpdate Set db = CurrentDb db.Execute strUpdate, dbFailOnError Set db = Nothing </code></pre> <p>However, if you prefer to build the literal date values from those text boxes into your <code>UPDATE</code> statement, you can use <code>Format()</code>.</p> <pre class="lang-vb prettyprint-override"><code>"AND FinishDate BETWEEN " &amp; _ Format(Forms!frmMainmenu!txtFirstDate, "\#yyyy-m-d\#") &amp; _ " AND " &amp; Format(Forms!frmMainmenu!txtEndDate, "\#yyyy-m-d\#") &amp; ";" </code></pre> <p>Either way, using a string variable to hold your <code>UPDATE</code> statement gives you an opportunity to examine the completed statement you're asking the db engine to execute.</p> <p>You can view the output from <code>Debug.Print</code> in the Immediate window (go there with <kbd>Ctl</kbd>+<kbd>g</kbd>). For troubleshooting, you can copy the statement text from there and then paste it into SQL View of a new Access query.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload