Me.Dirty "Do you wish to save?" how to on unbound form?

The same way you would refer to a table (or query) cell in vba, for instance:
Code:
=Tables![yourTableName]![field]
works for a single record table, or a singe record result in a query;
Code:
=Tables![yourTableName]![field](index)
may work for a multi-record table/query (not sure about syntax here).
 
thanks. Will test it. Though I still can't understand how it works. Does it update the table? If the form is not bound to the table, how a new record is added to the table or you can edit a record?
 
thanks. Will test it. Though I still can't understand how it works. Does it update the table? If the form is not bound to the table, how a new record is added to the table or you can edit a record?
Edit, IDK about add.
 
Edit, IDK about add.
If you can't add new record, then how you edit a record. The form is not bound so can not move through the records of the table. If you edit the value of the text box, which record of the table will be edited? the first one? the last one?
 
If you can't add new record, then how you edit a record. The form is not bound so can not move through the records of the table. If you edit the value of the text box, which record of the table will be edited? the first one? the last one?
If the table/query only has one record, then it isn't a problem. For instance, I use a database table to assign names of units to an entity, it only has one record - the current one. So there is no need to specify which record, it uses the only one. Hypothetically speaking, if one changes the value in such a textbox, it should change the value in the table (but I normally use them in locked textboxes). It is not intended for adding records, but, hypothetically speaking, should also edit when changed.

Otherwise, I think that maybe the OP should be using a bound form - create a new table for his changed settings, and disallow new records (after the first record is added). This would save the contents for use at a later date.
 
It doesn't work for me. I receive #Name? error with =Tables![yourTableName]![field] as record source.

But never mind. I won't use this method even if it works. It makes no sense for me. I prefer to write a function as the record source or use a DLookup if I need to refer to a field in a table..

Thanks anyway.
 
Last edited:
I even tried the builder which gave me =[Table1]![Field1] and I got #Name? :unsure:
 
I see. I had to open an old database backup save to read this, as I had replaced all these with vba assignment instead. It turns out I was mistaken, it was:
Code:
=DLookUp("[FieldName]","[TableQuery]")
So (with mud on my face) 🥵 I was wrong, you can't save to the table/query this way through DLookUp. Oops.
I think we will have to wait for the OP to elaborate on his db.
 
Of course, the simple answer is to use a bound form when data is saved automatically (provided any validation checks are satisfied)
There are very few good reasons for ever using an unbound form
 

Users who are viewing this thread

Back
Top Bottom