Hello - I have searched this website for an answer to my question and I can't find anything that will work the way I need it to work.
I have a main form with a button on it called "add record". When the user clicks the button another form is called where the user can add records. This form is based on a table that has a key field in it (level1_key) that is numeric. When the user clicks "add record" from the main form - when the next forms opens - I want the level1_key field to automatically populate with the next available number from the table.
I don't want to set the field as an auto number field because of some other linking issues I have with this and other tables. I want to accomplish this programatically. I've tried putting a SetValue macro action on the "add record" button. On the SetValue macro action I have the following code:
ITEM: [Forms]![frmLevel1]![fldLevel1_key]
EXPRESSION: DMax([tblEvidence_Location]![fldLevel1_key],[tblEvidence_Location])+1
This seems like it should work but I'm getting an error when this code is in. Can anyone tell me the easiest way to accomplish this?
thanks!
Caitlin
I have a main form with a button on it called "add record". When the user clicks the button another form is called where the user can add records. This form is based on a table that has a key field in it (level1_key) that is numeric. When the user clicks "add record" from the main form - when the next forms opens - I want the level1_key field to automatically populate with the next available number from the table.
I don't want to set the field as an auto number field because of some other linking issues I have with this and other tables. I want to accomplish this programatically. I've tried putting a SetValue macro action on the "add record" button. On the SetValue macro action I have the following code:
ITEM: [Forms]![frmLevel1]![fldLevel1_key]
EXPRESSION: DMax([tblEvidence_Location]![fldLevel1_key],[tblEvidence_Location])+1
This seems like it should work but I'm getting an error when this code is in. Can anyone tell me the easiest way to accomplish this?
thanks!
Caitlin