Incremented Value is not populating Table

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a value that should be incrementing automatically (from a query) when
a form opens. However, the new value is not populating the table. So when I
go to open an new form, I am not getting a new incremented value.

Here is my code.

Private Sub Form_Open(Cancel As Integer)

txt_Contract_Main_No = 1 + Nz(DMax("Contract_Main_No",
"Qry_Int_Contracts_Main"), 0)

End Sub

The reason I have it looking to the query for the next number is because I
have two ranges of numbers and instead of having two separate tables, I
thought I would just run a query for each set of number and have my form
based off of each query (just in case that was important to figuring out this
problem).

Is there something else I need to do to get the new incremented number to
populate my table?

As always, any help is appreciated.
 
When you open a form, the form is usually based on a table or query, This is
where the data comes from. If you are in ADD mode the form will be blank
awaiting input of new data. When you enter new data the underlying table is
not actually updated until you navigate to a different record.
Are you seeing your calculated number on the form?
Did you try putting a msgbox after your calculation to see if the value is
what you want?

Dorian
 
Hi Dorian,

The msgbox revealed that it is not the value I want. When I move to a new
record after entering the rest of the data on the form, the new record is
created, however, and all the fields are populated from the form I used
except for the incremented value (calculated field). So when I go to enter a
new record, I get the same value in the text box control that was in the
previous record.
 
Back
Top