FoxProProgrammer
Programmer
I am creating a form that will be used to add new records to a database. The table contains four fields, one of which is a foreign key to its parent table. I use DoCmd.RunCommand acCmdSaveRecord to save the record when the user presses the “Save” button on the form. I don’t want to display the foreign key on the form because it isn’t needed. The foreign key is the selected value of a combo box on another form. The only way that I have gotten this to work is to create a hidden text box on the form, whose value is assigned with [Forms]![form name]![control name].
Is this how this is typically done or is there a better way? It seems rather convoluted to create a control on the form that is hidden just so the data is saved with the record. Is there a way to assign the value of a field in a table? If there’s a way to do that, I could save the three fields with the DoCmd and then save the foreign key after that. This seems dangerous because if the record pointer changes between the time the first three fields are saved and the fourth field, the data would get corrupted. I realize that there is more than one way to code, but I am trying to do this in a manner that is most consistent with good programming practices in Access, if that even exists.
Thanks for any suggestions.
dz
Is this how this is typically done or is there a better way? It seems rather convoluted to create a control on the form that is hidden just so the data is saved with the record. Is there a way to assign the value of a field in a table? If there’s a way to do that, I could save the three fields with the DoCmd and then save the foreign key after that. This seems dangerous because if the record pointer changes between the time the first three fields are saved and the fourth field, the data would get corrupted. I realize that there is more than one way to code, but I am trying to do this in a manner that is most consistent with good programming practices in Access, if that even exists.
Thanks for any suggestions.
dz