title: Access 2002 VBA: Creating an incremented Item Code
body: <p>Ok, here's the deal. I have a previously existing SQL Server 2008 database linked to an Access 2002 database via linked tables/views. Up until now, the item code has been a <code>nvarchar</code> type. </p>
  
  <p>I have a SQL query which casts the item codes as <code>Int</code> and an Access 2002 linked query that uses the <code>MAX()</code> function to give me the highest value.  It is from this highest value I wish to start incrementing the item codes by 1 every time the "New" record button is selected.</p>
  
  <p>Right now, when "New" is selected, the form is blank, waiting for input. What I want to do is, when "New" is selected, to have the value of the <code>MAX()</code> function query passed to a variable, have 1 added to it, and the resulting value placed in the "Item Code" text box.  </p>
  
  <p>It sounds easy enough, but for some reason I can't seem to get it to work.  I know Access fairly well, but my VBA is fairly weak.</p>