Problems with DMax +1

  • Thread starter Thread starter Tina
  • Start date Start date
T

Tina

Here's my setup. I have a form with a subform.

The form has the following controls on it....

Customer ID- This is a combo box that uses Customer ID
and Customer Name to pull up records in the subform.

Customer- This control takes it's name from the combo box
with the following code. =ID.Column(1)

Then the Subform has the following controls...

Employee
Customer ID---Automatically filled in from the combo box.
Customer
System_ID
System
Location
City

Then 2 command buttons, Add Record and Delete Record....

This all works perfectly but I can't get the finishing
touch to work. When I click on the "Add Record" button I
want the next available System_ID number to be filled in
per the Customer ID. It was suggested that I use DMax +1
but I've tried different versions of code and I keep
getting error messages...

I want to be able to select customer, click add, then have
the next number in the sequence for System_ID for each
individual customer to fill in the System_ID text box.


Any advice that can be offered would be greatly
appreciated!!! Thanks again for any advice!
 
HI Tina!
I've just tried the Dmax +1 and it works ok..
Here my code:

dim res as Long
res = DMax("ClientNo", "clients") + 1
In your case it would look soemthing like this:
res = DMax("System_ID", "NameOfYourTable") + 1

I hope that you wish to add +1 to the Max found in the
column 'System_ID'. If this is the case then
replace 'NameOfYourTable' by the name of the table
which 'System_ID ' is a part of and that sould do the
trick..
The 'res' should then be used as the new 'System_ID'
number for that new user/client.

hope this helps,
PAtrick
 
Back
Top