L
Larry
I have a subform, of locations for the user defined on the main form. Each
user can have multiple locations. The subform is a single record form and
has a field for "Order", to describe which order the locations will print on
any reports.
The problem I am having is when I want to set the default value for the
Order textbox. I want Order to be 1 for a new record, or 1 greater than the
highest Order for the current user.
I put the following code in the OnCurrent even of the subform:
If Me.NewRecord Then
Me.txtOrder.DefaultValue = """" &
Cstr(NZ(DMax("Order","tblPersonnelLocation","PersonnelID = " &
Me.Parent.PersonnelID),0) + 1) & """"
End if
When I have this code in place and open the form, MS Access crashes with a
msg about needing to repair/restart my database. If I put a break on the IF
part of the statement and step through it, IT WORKS! But, somehow, I don't
think I want my users having to do that.
I also tried this without the IF statement, just doing it for every record,
and that didn't work. I also tried putting the value in a string variable
first, then assigning that to the DefaultValue property, and it didn't help.
I have also tried putting this formula on the property line itself, with no
success.
Anyone have an idea what might be causing this problem?
BTW, Access 2002 SP 3 on Windows XP.
TIA
Larry
user can have multiple locations. The subform is a single record form and
has a field for "Order", to describe which order the locations will print on
any reports.
The problem I am having is when I want to set the default value for the
Order textbox. I want Order to be 1 for a new record, or 1 greater than the
highest Order for the current user.
I put the following code in the OnCurrent even of the subform:
If Me.NewRecord Then
Me.txtOrder.DefaultValue = """" &
Cstr(NZ(DMax("Order","tblPersonnelLocation","PersonnelID = " &
Me.Parent.PersonnelID),0) + 1) & """"
End if
When I have this code in place and open the form, MS Access crashes with a
msg about needing to repair/restart my database. If I put a break on the IF
part of the statement and step through it, IT WORKS! But, somehow, I don't
think I want my users having to do that.
I also tried this without the IF statement, just doing it for every record,
and that didn't work. I also tried putting the value in a string variable
first, then assigning that to the DefaultValue property, and it didn't help.
I have also tried putting this formula on the property line itself, with no
success.
Anyone have an idea what might be causing this problem?
BTW, Access 2002 SP 3 on Windows XP.
TIA
Larry