Unanswered: Updating a field in a open or current record
Can someone explain to me if my understanding of this subject below is correct?
If I have a form open to "add" records and I am currently in the middle of the form, what state is that record in. I know obviously it is not closed, has the record been created yet? The issue I have is: can I edit or update a field with a VBA subroutine before the record is closed?
If so how? Can someone show me?
The table is called allocation and the field to update is QTY_Allocated
I appreciate anyone's input and support on this because it is kicking my butt.
Easy enough to test. Start a record, then open the table and see if it's there yet. As a rule it would not yet be created. Your VBA could simply modify the value on the form. If you want to modify the value directly in the table, you'd probably have to force a save first.
Good enough, and you are correct it is not there.....of course. I was hoping to not have to put the value on the form since the user is prompted for the value ( which BTW is a integer for quantity) in the VB Code.
Are you saying if I put the field on the form, I can update it? Using the VB Code? If so it is not a value that I want the user to be able to change unless the entire order entry is cancelled.
If the value is part of the record being displayed on the form, then it is certainly simplest to have it on the form. It can be hidden from the user, or locked so they can't change it. In whatever your VBA code is, at the end:
Me.TextboxName = YourDesiredValue
which will work with a hidden, disabled or locked textbox bound to the underlying table.
Thanks this makes sense and what I will do. Two more simple questions I hope. Do I bind the text to an entire table or just the field ? Lastly, I hate to ask, but how does the textbox get bound to a table?
Well, a textbox can only be bound to a field in a table if the form is bound to that table. That's why I said "If the value is part of the record being displayed on the form". The form's record source property determines what it's bound to, the textbox's control source property determines which field of the form's source it's bound to.